URL Detection
Moderator: General Moderators
URL Detection
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?