使用完全相同的 .htaccess 文件,我的本地 LAMP 服务器(通过 mamp pro)和生产服务器的行为不同。我想有一个不同的配置处于危险之中,但是哪一个呢?
在我的本地服务器上,http: //domain.com/section/item/ 正确重定向到http://domain.com/index.php?section= $1&item=$2
在我的生产服务器上, http: //domain.com/section/item/ 可以访问 http://domain.com/section/item/index.html
我该怎么做才能使生产服务器表现得像开发服务器?
这是 htaccess 文件内容,以防万一。
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks
#--------------------------------------------
# PRETTY URLS
#--------------------------------------------
# if the following conditions are met, SKIP the rewriteRules.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]
# Externally redirect to add missing trailing slash
RewriteRule [^/]$ %{REQUEST_URI}/ [R,L]
# SIX PARAMS
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2&menu=$3&content=$4&id=$5&title=$6 [NC,L,QSA]
# FIVE PARAMS
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2&menu=$3&content=$4&id=$5 [NC,L,QSA]
# FOUR PARAMS
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2&menu=$3&content=$4 [QSA,L]
# THREE PARAMS : projects/touch/texts/
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2&menu=$3 [QSA,L]
# TWO PARAMS: downloads
RewriteRule ^downloads/([^/]+)/$ index.php?section=downloads&item=$1 [QSA,L]
# TWO PARAMS:
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2 [QSA,L]
# TAG URL : index.php?tag=url+encoded+keyword
RewriteRule ^tag/([\w-]+)/$ index.php?tag=$1 [NC,L,QSA]
# ONE PARAM
RewriteRule ^([\w-]+)/$ index.php?section=$1 [L,QSA]
#--------------------------------------------
# END PRETTY URLS
#--------------------------------------------
</IfModule>