php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75528 Ignoring vhost document root when using php-cgi.exe in Apache2.4
Submitted: 2017-11-15 20:07 UTC Modified: 2018-05-05 13:05 UTC
From: eziitiss at gmail dot com Assigned: ab (profile)
Status: Closed Package: CGI/CLI related
PHP Version: 7.1.11 OS: Windows 10 1703 x64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: eziitiss at gmail dot com
New email:
PHP Version: OS:

 

 [2017-11-15 20:07 UTC] eziitiss at gmail dot com
Description:
------------
Using apache2.4.29 x64 from ApacheLounge with mod_fcgid and php 7.1.11 nts.
Have configured 2 virtual hosts each using a different path:
vhost 1 path: c:/Apache24/htdocs
vhost 2 path: c:/website

under htdocs: exists one file index.php
under website: exists 2 files index.php and index.html

When calling vhost1/index.php - page opens as expected
When calling vhost2/index.html - page opens as expected
When calling vhost2/index.php - instead of opening index.php from website folder, it opens index.php from htdocs folder.

The php script inside the index.php files is only an echo with page name where I have been landed.

When I remove from apache config file php-fcgi integration all works as expected (correct php code is displayed as uninterpreted text)

fcgi configurationL
<IfModule fcgid_module>
	# Where is your php.ini file?
	FcgidInitialEnv PHPRC        "c:/php7111nts" 

	AddHandler fcgid-script .php  
	FcgidWrapper "c:/php7111nts/php-cgi.exe" .php
</IfModule>

Vhost configuration:
<VirtualHost *:80>
    DocumentRoot "c:/Apache24/htdocs"
    ServerName localhost
	<Directory "c:/Apache24/htdocs">   
		Options Indexes FollowSymLinks MultiViews ExecCGI
		AllowOverride None
		Require all granted
	</Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "c:/website"
    ServerName test.dev
	<Directory "c:/website">   
		Options Indexes FollowSymLinks MultiViews ExecCGI
		AllowOverride None
		Require all granted
	</Directory>
</VirtualHost>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-11-16 17:54 UTC] eziitiss at gmail dot com
I was able to workaround it myself by disabling the doc_root parameter in php.ini file and enabling cgi.force_redirect. Still, this behavior was not the expected one. I  would expect that pages outside the doc_root directory would not work at all, not displaying the page that's inside the doc_root directory.
 [2018-05-05 13:05 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2018-05-05 13:05 UTC] ab@php.net
Thanks for the report. Apache won't be able to tell the difference with the configuration you use. Either it has to be a diferent host name, or different port. Please check Apache documentation for the further info.

Thanks.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 11:01:34 2025 UTC