【发布时间】:2019-05-17 09:35:18
【问题描述】:
我的服务器环境是Apache,版本是Apache/2.4.18 (Ubuntu)
站点配置文件如下:
<VirtualHost *:80>
DirectoryIndex index.html index.php
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule (.*) - [END]
# Else proxy
RewriteRule ^/(.*)$ http://127.0.0.1:60000/$1 [P,QSA]
ProxyPassReverse / http://127.0.0.1:60000/
ProxyPreserveHost On
</VirtualHost>
当我访问只有index.php文件的目录时,会被反向代理,没有解析index.php
如果我把 DirectoryIndex 改成 index.php index.html 问题就解决了,但是在 index.html 中会出现上述问题。
而且我删除反向代理的时候,index.php和index.html都会正常,不会受顺序影响。
所以问题可能是:当反向代理存在时,Apache只识别第一个DirectoryIndex,如果不存在,它会反向代理而不是尝试后面的默认主页。
希望默认首页和反向代理能够和平共处。如何处理?
【问题讨论】:
标签: apache