項目下有.htaccess文件,里面配置了路由規則,如下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
升級前訪問域名(不帶路徑,比如http://www.juyunmall.com)會正確進入系統。
但在升級后,訪問域名卻把項目里面的文件列出來了(Options All),并沒有按規則進入index.php文件。
排查下來的原因是新版本apache,在訪問域名(不帶路徑,比如http://www.juyunmall.com)時RewriteCond %{REQUEST_FILENAME} !-d 這個條件是不成立的,導致沒有進入RewriteRule,猜測新版本把只訪問域名也當做對是對工作目錄對直接訪問了?
解決辦法,針對只訪問域名的情況再加上一個規則RewriteRule ^$ index.php [QSA,L],變成如下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>