1
我在Windows机器上本地设置了一个新站点进行测试。在文档根目录中,如果我有一个index.html
,它将在浏览器中正常使用。如果我将其重命名为index.php
,浏览器将不会收到任何内容。服务器端没有提出错误。我试图理解为什么。Apache 2.4:PHP文件没有被发送到浏览器
虚拟主机
<VirtualHost *:80>
DocumentRoot "C:\websites\learn"
ServerName learn.loc
LogLevel alert rewrite:trace2
#PHP SETTINGS
php_value auto_prepend_file "C:\websites\learn\noop.php"
php_value open_basedir "C:\websites\learn"
<Directory "C:\websites\learn">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
这里是.htaccess
文件驻留在文档根:
RewriteEngine on
#point to javascript learning project
RewriteRule ^js /javascript
RewriteRule ^js/(.*) /javascript/$1
下面是当我加载learn.loc/javascript
产生的mod_rewrite
日志(该文件夹具有一个index.php
文件)
[initial] [perdir C:/websites/learn/] pass through C:/websites/learn/javascript/
[subreq] [perdir C:/websites/learn/] pass through C:/websites/learn/javascript/index.html
[subreq] [perdir C:/websites/learn/] pass through C:/websites/learn/javascript/index.htm
[subreq] [perdir C:/websites/learn/] pass through C:/websites/learn/javascript/index.php
没有添加到Apache或PHP错误日志;浏览器本身接收status code 200
,具有以下响应头
Date: "..."
Server: "Apache/2.4.16 (Win32) PHP/5.6.23"
X-Powered-By: "PHP/5.6.23"
Content-Length: "0"
Keep-Alive: "timeout=5, max=100"
Connection: "Keep-Alive"
Content-Type: "text/html; charset=UTF-8"
的响应体是空字符串一起。就像我说的,如果我将文件重命名为index.html
,会显示内容(香草html文件)。可能会发生什么?