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文件)。可能會發生什麼?