5 Replies - 994 Views - Last Post: 02 October 2012 - 05:51 AM Rate Topic: -----

#1 nightscream  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 237
  • Joined: 04-December 08

Getting real url / path in php using mod rewrite

Posted 01 October 2012 - 01:30 AM

I've searched around the web but couldn't really find anything.

I want to know if this is possible. I have a url base/config.js which redirects to config.php with apache mod rewrite. Now I want to be able to fetch the real url from another file. Lets say index.php wants to know where config.js is stored.

Is there a way to do it with a function? I tried curl, url_parse, pathinfo, .... One thing I can do is reading htaccess file and get the right value.. but I think that's too much.

Or I can also put the exceptions in an array but I kinda want to make it dynamic.

This post has been edited by nightscream: 01 October 2012 - 01:32 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Getting real url / path in php using mod rewrite

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3489
  • View blog
  • Posts: 10,057
  • Joined: 08-June 10

Re: Getting real url / path in php using mod rewrite

Posted 01 October 2012 - 01:36 AM

PHP files are perfectly capable of serving JS content, so why not directly serve it instead of a rewrite?
Was This Post Helpful? 1
  • +
  • -

#3 nightscream  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 237
  • Joined: 04-December 08

Re: Getting real url / path in php using mod rewrite

Posted 01 October 2012 - 05:40 AM

Because I want them to look pretty as .js
Was This Post Helpful? 0
  • +
  • -

#4 KingCuddles  Icon User is offline

  • D.I.C Regular

Reputation: 176
  • View blog
  • Posts: 496
  • Joined: 20-December 08

Re: Getting real url / path in php using mod rewrite

Posted 01 October 2012 - 08:46 AM

View Postnightscream, on 01 October 2012 - 01:40 PM, said:

Because I want them to look pretty as .js


Frankly the file extension is really the last thing to worry about. I would follow Dormilich's advice!
Was This Post Helpful? 0
  • +
  • -

#5 nightscream  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 237
  • Joined: 04-December 08

Re: Getting real url / path in php using mod rewrite

Posted 02 October 2012 - 05:09 AM

I wrote a mapper :P sorry I don't like .php for other files than php. I rather have my users not knowing
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3489
  • View blog
  • Posts: 10,057
  • Joined: 08-June 10

Re: Getting real url / path in php using mod rewrite

Posted 02 October 2012 - 05:51 AM

since you rewrite that information on server level (at the HTTP recipient), there is no way for an external source to find out the internal file.

View Postnightscream, on 02 October 2012 - 02:09 PM, said:

I don't like .php for other files than php.

HTML files ainít PHP files either, yet you serve PHP as HTML. ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1