.htaccess 重定向url,如果它包含一些单词集

.htaccess 重定向url,如果它包含一些单词集,.htaccess,redirect,.htaccess,Redirect,我喜欢htaccess将包含一些单词的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/ 上面的例子将任何包含fun、play和give的url重

我喜欢htaccess将包含一些单词的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/

上面的例子将任何包含fun、play和give的url重定向到主页

我找到了

RewriteCond %{REQUEST_URI} foobar
RewriteRule .* index.php
但它只重定向了一个词


谢谢

以下内容应能满足您的需求

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]
以上内容将重定向任何包含字符串的url

e、 g.以下网址:


将全部重定向到:

您可以在root.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]