【发布时间】:2013-09-27 16:38:17
【问题描述】:
使用完全相同的 .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>
【问题讨论】:
-
开发服务器和生产服务器上是否都存在
/section/item/index.html? -
是的,两个文件目录结构完全一样。
标签: apache .htaccess mod-rewrite