2009-04-30 79 views
0

我正在本地开发应用程序(在域名<mydomain> .dev)。mod_rewrite:为什么它在本地工作而不是在线?

为了与友好的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变量。为什么?

+0

会是怎样正确的重定向目标http://mydomain.eu/issue/my-slug/#23? – pts 2009-04-30 22:36:43

回答

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 
0

我没有看到

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

应该匹配的URL,但多数民众赞成与[R]标志是唯一一个做一个外部重定向。尝试对此进行评论,以确保应用程序中没有其他部分执行重定向。我的猜测是有。

0

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

RewriteRule ^([a-z0-9._-]+/)*[a-z0-9_-]+$ %{REQUEST_URI}/ [NC,R=301,L] 
相关问题