Joshua Honig
Joshua Honig

Reputation: 13215

PHP is adding the drive name to the start of all URLs

Short version: PHP (or Apache??) is appending "C:" to the start of all relative URLs. How can I make it stop doing this?

Detail: I'm trying to set up an AMP stack by hand on Windows Vista. This is just for internal use on my home network.

I've installed Apache 2.2, MySQL, and PHP 5.4. Everything's good except that PHP is appending "C:" to the beginning of every single URL. For example, even calling php_info() shows that php is adding "C:" to the start of SCRIPT_PATH and PHP_SELF. This is despite the fact that the DOCUMENT_ROOT variable is correct (C:\Apache2\htdocs):

From the PHP Variables section:

      Variable               Value
------------------------   ---------------
_SERVER["REQUEST_URI"]     /test.php
_SERVER["SCRIPT_PATH"]     C:/test.php
_SERVER["PHP_SELF"]        C:/test.php
_SERVER["DOCUMENT_ROOT"]   C:/Apache2/htdocs

Is there some setting I need to change in php.ini to correct this? It's totally screwing up links, such that I get lots of error messages like this in my Apache logs:

[error] [client 10.0.0.4] (20023)The given path was above the root path: Cannot map GET /C:/<rest of the actual path>

I've compared both php.ini and the Apache httpd.conf to the same files for an XAMPP installation on my laptop (which does not have this problem) and I cannot see any differences that seem like they would cause such a phenomenon.

This problem has ocurred with both Apache 2.4 + PHP 5.5 (both compiled with VC11) and with Apache 2.2 + PHP 5.4 (both compiled with VC9).

Upvotes: 2

Views: 111

Answers (2)

user3075978
user3075978

Reputation: 845

I just had this same problem and I fixed it by setting "FcgidFixPathinfo" to 0 in Apache's httpd.conf file. Here's a link to where I found this.

http://www.apachelounge.com/viewtopic.php?p=18659

Upvotes: 1

RiggsFolly
RiggsFolly

Reputation: 94672

There must be something subtley wrong with your config I would assume, what it is I cannot guess.

However if you are not interested in the challenge of installing an AMP stack manually and you just want something that does it all in one simple ready to go install, can I suggest you have a look at WAMPServer.

This installs Apache/MySQL and PHP in a one click install.

I suggest you make sure you have uninstalled all your other attempts at installing Apache and MySQL before you try WAMPServer as they will undoubtedly cause confusion.

Just a suggestion!

Upvotes: 0

Related Questions