我正在本地开发一个应用程序(在域名.dev下)。
为了使用友好的urls,我将我的.htaccess设置如下:
RewriteEngine on
# Externally redirect to add missing trailing slash
RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://example.com/$1/?%{QUERY_STRING}[NC,R,L]
RewriteRule ^about/$ about.php [NC,L]
RewriteRule ^issues/$ issues.php [NC,L]
RewriteRule ^issue/([a-z0-9_\-]+)/$ issue.php?slug=$1 [NC,L]
SetEnv PHP_VER 5
IndexIgnore *
Options +FollowSymLinks效果很好。令人烦恼的是,当你上网的时候,它就没那么好了:
http://example.com/issue/my-slug/#23不返回GET变量。为什么?
发布于 2009-04-30 22:49:52
根据过去的经验,我的猜测是RewriteBase,可能是因为您在共享服务器上,或者其他一些非标准配置。
RewriteEngine on
#Set base as doc root.
RewriteBase /
# Externally redirect to add missing trailing slash
RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://mydomain.eu/$1/?%{QUERY_STRING}[NC,R,L]
RewriteRule ^about/$ about.php [NC,L]
RewriteRule ^issues/$ issues.php [NC,L]
RewriteRule ^issue/([a-z0-9_\-]+)/$ issue.php?slug=$1 [NC,L]
SetEnv PHP_VER 5
IndexIgnore *
Options +FollowSymLinks发布于 2009-04-30 22:48:14
我看不出来
RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://mydomain.eu/$1/?%{QUERY_STRING}[NC,R,L]应该匹配该URL,但这是唯一一个具有R标志的外部重定向。尝试将该行注释掉,以确保应用程序中没有其他部分执行重定向操作。我猜是有。
发布于 2009-12-23 17:08:59
替换URL和标志之间缺少一些空格。您还可以将第一条规则简化如下:
RewriteRule ^([a-z0-9._-]+/)*[a-z0-9_-]+$ %{REQUEST_URI}/ [NC,R=301,L]https://stackoverflow.com/questions/809412
复制相似问题