0

I currently have my WAMP installation at:

C:/wamp/www/

My issue:

When calling $_SERVER['DOCUMENT_ROOT']; from localhost/projectname1/test.php - this outputs:

C:/wamp/www/

This is no good since path in my scripts will be wrong then. I this case I want Document root to output (which is my alias path for this dummy project):

C:\Users\SGS\Google Drive\_Work\projectname1\html/

All my working files are on google drive, so for each project I create an Apache alias, that points to the direct path of the project located on google drive folder.

Example of an alias created - projectname1.conf:

Alias /projectname1/ "C:\Users\SGS\Google Drive\_Work\projectname1\html/"

<Directory "C:\Users\SGS\Google Drive\_Work\projectname1\html/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order allow,deny
    Allow from all
</Directory>

This allow me to call the project with localhost/projectname1/

How do I get my document?

user1231561
  • 3,239
  • 6
  • 36
  • 55
  • http://sa-os.blogspot.com/2010/11/how-to-change-document-root-on-wamp.html ? – Sarah Kemp Jun 11 '13 at 19:58
  • Hi Sarah, thanks for the suggestion. I did actually already try this - however the issue with this is that it will make the document root "static" and regardless of projectfolder all reference to: C:/Users/SGS/Google Drev/_Work/ . As in my one project example - document root would need to reference to C:\Users\SGS\Google Drive\_Work\projectname1\html/ – user1231561 Jun 11 '13 at 20:58
  • All DOCUMENT_ROOT contains is the info from your server's configuration file. PHP doesn't follow WAMP's aliases like this. You might try deconstructing one of the other $_SERVER variables like here: http://stackoverflow.com/questions/4634869/php-how-to-get-the-document-root-from-inside-a-user-directory – Sarah Kemp Jun 11 '13 at 21:17

2 Answers2

0

I think you would be better creating a Virtual host for each of your projects.

HowTo setup Virtual Hosts

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
0

The problem with SCRIPT_NAME is that it is not static because it is based on the name of current executing script. Before Apache 2.3.x becomes popularly adopted so that we can use CONTEXT_PREFIX variable, I'm afraid there's no solution.

devXen
  • 3,013
  • 3
  • 35
  • 44