URL Detection

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GameMusic
Forum Newbie
Posts: 24
Joined: Fri Oct 28, 2005 8:33 pm

URL Detection

Post by GameMusic »

I don't like hard-coding directory or URL information in my scripts. But redirects require them, so I normally use SCRIPT_URI. However, in a recent script SCRIPT_URI wasn't set for some reason. So what I want to find out is, of the many environment variables that include URL information, which are the most preferable and reliable? And is there a method more reliable or portable than environment variables? What would be the safest way to find the URL (not the filesystem path) to the current directory, given that, for example, a query string might include slashes, or even use slashes as delimiters, especially when using mod rewrite?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply