$_SERVER["SCRIPT_URL"]: when is it reliably present?

clami219 picture clami219 · Jun 26, 2014 · Viewed 7.2k times · Source

In my local environment (PHP 5.4.24 on Apache 2.2.26) $_SERVER["SCRIPT_URL"] is present, but I read around that this variable is not always present, even though I couldn't find exactly when it is and when it isn't.

I'd like to know what is required for this variable to be reliably present.

Answer

Wolfgang Stengel picture Wolfgang Stengel · Jun 26, 2014

It's only available when you have mod_rewrite enabled:

http://httpd.apache.org/docs/2.0/rewrite/rewrite_intro.html#EnvVar