.htaccess 301重定向在重定向的URL中保留问号和变量

时间:2014-12-08 13:34:26

标签: apache .htaccess redirect

大家好,谢谢你的时间。

所以我在.htaccess中搜索了一行,我可以使用它来重定向网址,如:

产品类别/蛇形滑轮-KIT /沃尔沃五/?的OrderBy =普及

到mydomain.com/wheretopurchase /

当我这样做的时候,它会将?orderby = popular添加到新网址的末尾,如

mydomain.com/wheretopurchase/?orderby=popularity

有人可以帮助我从那里获取网址的最后一部分并干净地重定向吗?

再次感谢大家花时间帮助我。

1 个答案:

答案 0 :(得分:0)

您可以使用:

RewriteEngine on 
RewriteRule ^product-category/serpentine-pulley-kit/volvo-penta/?$ http://example.com/wheretopurchase/? [R=302,L]

如果?orderby=popularity对测试很重要,可以添加(在RewriteRule之前)

RewriteCond %{QUERY_STRING}  ^orderby=popularity$

当测试工作正常时,更改[R=302] [R=301]

相关问题