Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Dynamic Subdomains and PHP's DOCUMENT ROOT


TheMadScientist - 4:17 pm on May 8, 2008 (gmt 0)


I understand (I think), but for DOCUMENT_ROOT to = /Users/mdeclair/Sites/coolsite.com the current running script will have to physically be located in /Users/mdeclair/Sites/coolsite.com.

Let me give you a 'for instance'...

If you do not have a physical directory called /Users/mdeclair/Sites/coolsite.com, with the file located within the directory, DOCUMENT_ROOT will return the incorrect location.

IOW If you 'dynamically create' the directories for use, and then rewrite the directory to another location to access the script you will receive the location of the script with DOCUMENT_ROOT, but will receive the 'virtual location' using PATH_TRANSLATED or SCRIPT_FILENAME.

EG

If the script is located at /Users/mdeclair/Sites/awesomesites.php but runs when /User/mdeclair/Sites/awesomesite.com/ is opened, you will receive the incorrect location using DOCUMENT_ROOT, because it gives you the physical server path to the actual location of the current script, not a rewritten or dynamically generated path.

If the script is physically located at /User/mdeclair/Sites/awesomesite.com/index.php then DOCUMENT_ROOT *should* give you the correct path/location. If the script is physically stored in another location on the server, then you will have to use one of the other server variables to return the current 'dynamic' location of the request.


Thread source:: http://www.webmasterworld.com/apache/3640691.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com