重写了在.htaccess组合无效 [英] Combination of rewrites in .htaccess doesn't work
本文介绍了重写了在.htaccess组合无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的.htaccess文件不同的规则,单独工作正常,但合并在一个文件中,他们没有。 下面是我的文件的一些例子:
I have different rules in my .htaccess file which work fine individually but combined in one file they don't. Here are some examples of my file:
# take care of %C2%A0
RewriteRule ^(.+)\xc2\xa0(.+)$ $1-$2 [L,NE]
# executes **repeatedly** as long as there are more than 1 spaces in URI
RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [L,NE]
# executes when there is exactly 1 space in URI
RewriteRule "^productdetails/617/6/(\S*) (\S*?)/?$" /$1-$2/302 [L,R=302,NE]
此外,我已经得到了以下内容:
Also I've got the following:
RewriteCond %{QUERY_STRING} ^pid=617/?$
RewriteRule ^productdetails\.asp$ /Casio-CDP120-Digital-Piano-in-Black/302? [L,NC,R=301]
仍然正常工作。 我现在已经增加了以下内容:
which still work fine. I have now added the following:
RewriteRule "^categories/3/Kawai Digital Pianos/?$" /Compare/Kawai-Digital-Pianos [L,NC,R=301]
它用来改写:
which used to rewrite:
mysite.co.uk/categories/3/Kawai%20Digital%20Pianos/ to mysite.co.uk/Compare/Kawai-Digital-Pianos
这不工作了。
任何帮助,以获得最后一条规则结合工作与他人将是巨大的。
Any help to get the last rule working in combination with the others would be great
推荐答案
您只需要确保规则的顺序是正确的。对于你的例子如下顺序应该:
You just need to make sure order of rules is correct. For your examples following order should work:
RewriteRule "^categories/3/Kawai Digital Pianos/?$" /Compare/Kawai-Digital-Pianos [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^pid=617/?$
RewriteRule ^productdetails\.asp$ /Casio-CDP120-Digital-Piano-in-Black/302? [L,NC,R=301]
# take care of %C2%A0
RewriteRule ^(.+)\xc2\xa0(.+)$ $1-$2 [L,NE]
# executes **repeatedly** as long as there are more than 1 spaces in URI
RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [L,NE]
# executes when there is exactly 1 space in URI
RewriteRule "^productdetails/617/6/(\S*) (\S*?)/?$" /$1-$2/302 [L,R=301,NE]
这篇关于重写了在.htaccess组合无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文