2016-04-21 44 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] 

而且你可以刪除$來測試連話到另一個地方,最終