2014-03-29 29 views
2

我喜欢htaccess的重定向包含一些词语集的主页URL的重定向URL,如果它包含了一些词语集

例子:

重定向

www.mywebsite.com/folder/dont-stop-the-fun 
www.mywebsite.com/folder/dont-fun-stop-the 
www.mywebsite.com/folder/play-the 
www.mywebsite.com/folder/dont-fun-give-the 

www.mywebsite.com/

上面的例子重定向任何包含的url NS的乐趣,玩&给主页

我发现

RewriteCond %{REQUEST_URI} foobar 
RewriteRule .* index.php 

但它重定向只有一个字

感谢

回答

0

您可以使用根的.htaccess规则:

RewriteEngine on 

RewriteRule ^folder/(dont-stop-the-fun|dont-fun-stop-the|play-the|dont-fun-give-the) /index.php? [L,NC,R=301] 
0

下应该达到你在找什么

RewriteEngine on 
RewriteCond %{REQUEST_URI} dont-stop-the-fun [OR] 
RewriteCond %{REQUEST_URI} dont-fun-stop-the [OR] 
RewriteCond %{REQUEST_URI} play-the   [OR] 
RewriteCond %{REQUEST_URI} dont-fun-give-the 
RewriteRule .* /index.php [R] 

以上将重定向任何包含它是任何地方的字符串。

例如以下网址:

http://example.com/dont-fun-give-the

http://example.com/dddd/ddd/ss/aa/dont-fun-give-the

http://example.com/hello-dont-fun-give-the

http://example.com/dont-fun-give-the-dog

都将被重定向到:http://example.com/index.php

相关问题