Forum Moderators: coopster

Message Too Old, No Replies

Paths in windows

how do I get a path to DOCUMENT_ROOT that will work in an .htaccess file?

         

mincklerstraat

8:47 am on Jun 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm working on the installation part of a script which requires writing an .htaccess file for an auto_prepend file.

When trying to get the script to work in Windows, a bunch of weird stuff happens.

$_SERVER['DOCUMENT_ROOT'] is available, but it comes out all-lowercase, and without the spaces transformed to whatever it is that windows uses as a symbol for spaces. So I get something like:
c:/program files/apache group/apache/htdocs
for this value, when actually a number of those letters are uppercased. Since the spaces aren't taken care of, in an .htaccess file, this line is interpreted so as to mean a number of different values since htaccess values are space-separated. Anybody know how to get the document root, with uppercase stuff intact (I suppose windows will be case-sensitive when it comes to including files), and with the spaces taken care of? I don't need the value just to install on this box - I need to get it from the $_SERVER array or with ini_get so the script can be installed automatically.

mincklerstraat

9:14 am on Jun 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, I think I resolved it sort of - it seems the filesystem in windows looks for files on a case-insensititve basis, and the path with spaces in it can just be used as-is in the .htaccess file, as long as there are double quotes around it.

mcibor

9:15 am on Jun 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Windows isn't case sensitive even with file include. I don't know what is the character for space in windows, but you can always write c:\progra~1\apache~1\
This should work (Windows is soo stupid).

Hope this helps you somehow
Best regards
Michal Cibor

PS Good for you that you solved it!

coopster

4:33 pm on Jun 4, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm not sure how Apache/PHP reads the DOCUMENT_ROOT, but I would assume right from the OS somehow. I changed the path to lowercase letters in the Document Root in my Apache Configuration on one of my Windows test/development boxes, restarted Apache and checked the DOCUMENT_ROOT $_SERVER variable. No change. "C:\Program Files ... " ... I also changed the related var in the php.ini file but got the same results.

The way you described it, I was expecting to see lowercase in the variable. Nope. Not in any of the vars dumped via Apache nor PHP. Must get it from the OS somehow?

Nothing to offer here, mincklerstraat, just something to ponder :-)

JamShady

3:37 am on Jun 6, 2005 (gmt 0)

10+ Year Member



The document root is set in the httpd.conf file within the virtual host settings for a particular site/url. You can have a different document root for different sites in this manner. Apache passes this information on to PHP.

I'm pretty sure space for windows is %20

mincklerstraat

10:30 am on Jun 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Michal, Coopster, Jam:

Thanks for the thoughts and advice, much appreciated.

I think I'll take Jam's word for it on where this value comes from; at any rate, things seem to work by getting it from $_SERVER['DOCUMENT_ROOT'] even though this is all lowercase and with spaces (just as long as you enclose the value in double quotes). You people sure know your windows platform better than I do. Trying to install on windows revealed that there was stuff I'd left out of the install script altogether so I'm back to a more comfortable OS to patch things up, but I'll return when I surely flub up on other windows issues with this script ;) When I'm back in windows I'll try to figure out where this weird value in lowercase came from and let you all know. At any rate, it was just a standard install of Apache 1 from apache.org and php from php.net, no special install package like xamp.

JamShady

12:29 pm on Jun 6, 2005 (gmt 0)

10+ Year Member



The lowercase is coming from your httpd.conf file where the document root is defined for that virtual site. As the OS is case-insensitive, the case doesn't matter. My doc root is C:\Web Sites, and it shows up exactly like that in PHP, without %20