2016-04-21 50 views
1

我有我的网站上生成的垃圾邮件网址列表。我想将这些网址重定向到首页。这些所有垃圾邮件网址都有销售或折扣网址。 http://www.example.com/7ukwjvo-ralph-lauren-big-sizes-sale 我想这重定向到http://www.example.comhtaccess重定向,如果URL有特定字

我已经试过htaccess的重定向,但没有工作

RewriteCond %{REQUEST_URI} /(sale|discount)/$ 
RewriteRule (.*) http://www.example.com/ [R=301,L] 

请提供此

回答

2

溶液与尝试:

RewriteEngine on 
RewriteCond %{REQUEST_URI} (sale|discount)$ [NC] 
RewriteRule^http://www.example.com/ [R=301,L] 

因为使用/(sale|discount)它只适用于单词在0之后。
而且(sale|discount)/$只有在最后的/之前。

您可以简单地使用(不RewriteCond):

RewriteRule (sale|discount)$ http://www.example.com/ [NC,R=301,L] 

而且你可以删除$来测试连话到另一个地方,最终