2012-07-25 81 views
0

我已经写了下面的重写规则的正常工作参数时没有参数(无页码,每页没有产品,没有排序顺序等)重写规则,以保持

RewriteRule ^(?!bench/).*cat_2.html(\.[a-z]{3,4})?(.*) "http\:\/\/www\.mysite\.co\.uk\/bench\/cat_2\.html\?mode\=allBrands" [R=301,L] 

这确保了Google对Google搜索结果进行了优化。所以

被改为

mode=allBrands将始终设置。

所以,如果我点击一个链接去

它被重定向到

这是第一页。

任何帮助将是伟大的。

+0

可能重复http://stackoverflow.com/questions/4071155/keep-url-parameters-with -htaccess-rewrite) – 2013-01-13 05:02:06

回答

0

你需要一个QSA标志添加到您的重写规则,使支架看起来像这样:

[R=301,L.QSA] 

这告诉Apache将任何现有的查询字符串附加到目标的新的查询字符串(mode=allBrands )。

+0

嗨,谢谢你。它增加了参数,但离开了orignal所以http://www.tdffashion.co.uk/bench/cat_2.html?mode=allBrands变成http://www.tdffashion.co.uk/bench/cat_2.html?模式= allBrands&模式= allBrands。如何在使用QSA之前删除额外的参数?谢谢 – 2012-07-26 18:31:43

+0

从RewriteRule的目标中删除'?mode = AllBrands'。查询字符串将自动附加。 – 2012-07-26 18:57:11