0

我正在本地开发一个应用程序(在域名<mydomain>.dev下)。

为了使用友好的 url,我设置了我的 .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 变量。为什么?

4

3 回答 3

0

我没看到

RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://mydomain.eu/$1/?%{QUERY_STRING}[NC,R,L]

应该与该 URL 匹配,但这是唯一一个带有 [R] 标志来执行外部重定向的 URL。尝试注释掉该行,以确保应用程序的其他部分没有执行重定向。我的猜测是有。

于 2009-04-30T22:48:14.543 回答
0

根据过去的经验,我的猜测是 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-30T22:49:52.933 回答
0

替换 URL 和标志之间缺少一些空格。您还可以按如下方式简化您的第一条规则:

RewriteRule ^([a-z0-9._-]+/)*[a-z0-9_-]+$ %{REQUEST_URI}/ [NC,R=301,L]
于 2009-12-23T17:08:59.350 回答