将查询字符串重定向到另一个URL

时间:2013-11-01 13:54:13

标签: regex apache .htaccess mod-rewrite

我正在尝试重定向以下网址

http://www.mydomain.com/catalogsearch/result/index/?brand=1076&mode=grid&product_category=5533&q=pro+restore    

到此网址:

http://www.mydomain.com/nsearch/?q=pro+restore

这是我用于htaccess中其他网址的代码:

RewriteCond %{REQUEST_URI} ^/catalogsearch/result/index/$
RewriteCond %{QUERY_STRING} ^brand=1076&mode=grid&product_category=5533&q=pro+restore$
RewriteRule ^(.*)$ http://www.mydomain.com/nsearch/?q=pro+restore [R=301,L]

但它不起作用。关于我缺少的任何想法?

由于

1 个答案:

答案 0 :(得分:1)

DOCUMENT_ROOT/.htaccess文件中试用此代码:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^brand=1076&mode=grid&product_category=5533&(q=pro\+restore)$ [NC]
RewriteRule ^catalogsearch/result/index/?$ /nsearch/?%1 [R=301,L]