遇到RewriteCond后,htaccess测试停止了

时间:2014-06-12 09:29:58

标签: .htaccess redirect drupal

我想将所有http://www.mywebsite.com/other/sub/paths重定向到http://mywebsite.com/other/sub/paths

我正在使用http://htaccess.madewithlove.be查看我的htaccess网址输出,然后再在网站上进行操作。我能够重定向我的页面,但测试在中途停止,并显示以下内容:

RewriteCond %{HTTP_HOST} ^www\.mywebsite\.com$ [NC]  This condition was met
RewriteRule ^(.*)$ http://mywebsite.com/$1 [L,R=301]
This rule was met, the new url is
http://mywebsite.com/index.php?q=sc?pract?aut The tests are stopped,
using a different host will cause a redirect

这是测试停止的错误吗? 我有以下未经测试的行(它们是在停止测试的RewriteRules之后)

RewriteCond %{REQUEST_FILENAME} !-f     
RewriteCond %{REQUEST_FILENAME} !-d     
RewriteCond %{REQUEST_URI} !=/favicon.ico   
RewriteRule ^ index.php [L]     
# Requires both mod_rewrite and mod_headers to be enabled.  
# Serve gzip compressed CSS files if they exist and the client accepts gzip.    
RewriteCond %{HTTP:Accept-encoding} gzip    
RewriteCond %{REQUEST_FILENAME}\.gz -s  
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]    
# Serve gzip compressed JS files if they exist and the client accepts gzip.     
RewriteCond %{HTTP:Accept-encoding} gzip    
RewriteCond %{REQUEST_FILENAME}\.gz -s  
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]  
#Serve correct content types, and prevent mod_deflate double gzip.  
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]   
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]

如果有任何帮助,我的网站将在drupal 6上托管。

1 个答案:

答案 0 :(得分:0)

来自http://httpd.apache.org/docs/2.2/rewrite/flags.html

[L]标志使mod_rewrite停止处理规则集。在大多数情况下,这意味着如果规则匹配,则不会处理其他规则。这对应于Perl中的最后一个命令,或C中的break命令。使用此标志指示应立即应用当前规则而不考虑进一步的规则。