【发布时间】:2012-10-29 12:05:39
【问题描述】:
我有以下 htaccess 重写规则。 防止循环的唯一规则条件最初是这样写的:
RewriteCond %{ENV:REDIRECT_STATUS} ^.
它以前工作得很好,直到它突然停止工作导致 Apache 显示网站的目录列表。
我必须将其更改为这种新形式,如下面的清单所示,才能让它再次工作:
RewriteCond %{ENV:REDIRECT_STATUS} 200
你知道这种行为的原因吗?
谢谢
RewriteEngine on
RewriteBase /
## Permanent 301
## Force to www. Un-comment in production.
RewriteCond %{HTTP_HOST} !^www\.myhost\.com [NC]
RewriteRule ^(.*) http://www.myhost.com/$1 [L,R=301]
## Permanent redirect rules for contents
RewriteRule ^argument/programming/?$ tags/programming [NC,L,R=301]
## Internal Redirect Loop Protection
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
## Maintenance page
#RewriteRule (.*) special/maintenance.html
## Specials
RewriteRule special/(.*) special/$1 [NC,L]
## Static resources
RewriteRule ^(.*\.(js|ico|gif|jpg|png|css|rss|xml|htm|html|pdf|zip|gz|txt))$ public/$1 [NC,L]
## Front Controller
RewriteRule ^(.*) public/index.php [NC,L]
【问题讨论】:
-
你有没有得到这个答案?
-
其实不是 :( 还不错,只要它工作正常,我还是很想了解原因:)
标签: regex apache .htaccess mod-rewrite