I have a site in a subdirectory e.g. root/sites/testsite/ and I would like the php variable $_SERVER['DOCUMENT_ROOT'] to be root/sites/testsite/ and not root, how would I do this being in mind I am on shared hosting?
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
$_SERVER['DOCUMENT_ROOT']is automatically set to theDocumentRootconfigured in your ApacheVirtualHostconfiguration entry. This will be the directory pointed to by the URL/on your domain.You will need to change the code to use a different variable to calculate the base directory, such as one hard-coded in a config file. You may also be able to use the Apache
SetEnvdirective in a.htaccessfile to pass in a variable – e.g.SetEnv BaseDir root/sites/testsite/would result in$_SERVER['BaseDir']being set to the string"root/sites/testsite/".Alternatively, you could assign a new value to the variable at the beginning of the script, in order to “spoof” its value (for instance if using 3rd-party code that relies on this variable).