2014-09-24 84 views
1

请帮助解决这些重定向:的.htaccess重定向页面变量

重定向1.类/选项=值=> domain.com/category/page.html

RewriteCond %{QUERY_STRING} ^option=value(&.*)?$ [NC] 
RewriteRule ^category/$ http://domain.com/category/page.html%1 [R=301,NE,NC,L] 

重定向2.类别/子%26-类别/?选项=值=> domain.com/category/page1.html

RewriteCond %{QUERY_STRING} ^option=value(&.*)?$ [NC] 
RewriteRule ^category/sub-\x26-category/$ http://domain.com/category/page1.html%1 [R=301,NE,NC,L] 

回答

1

您需要使用?在目标URI去掉所有现有的查询字符串:

RewriteCond %{QUERY_STRING} ^option=value(&.*)?$ [NC] 
RewriteRule ^category/$ /category/page.html? [R=301,NE,NC,L] 

RewriteCond %{QUERY_STRING} ^option=value(&.*)?$ [NC] 
RewriteRule ^category/sub-\x26-category/$ /category/page1.html? [R=301,NE,NC,L] 

确保这些规则被放置在其他内部路由规则。

+0

>确保将这些规则放置在其他内部路由规则之上。 – 2014-09-24 20:29:51

+0

非常感谢,我添加了重定向到.htaccess的开始,他们现在工作 – 2014-09-24 20:30:40

+0

不客气,很高兴它解决了。 – anubhava 2014-09-24 20:32:29