我发现这个规则很好,只有一个条件,那就是:foobar在字符串中。
我需要将其更改为包含一个新条件,使其具有两个条件(而不是一个):
foobar在字符串中。这已经起作用了。meetball不在字符串中。
RewriteRule ^(.*)foobar(.*)$ http://www.example.com/index.php L,R=301发布于 2021-04-08 10:39:51
请试着按照你所展示的样本写下来。另外,您需要创建组(.*),因为您在重定向时没有使用它们。您可以添加apache的NC标志,以便在URI值中启用ignorecase。
RewriteEngine ON
RewriteRule ^(?!.*metaball).*foobar.*$ http://www.example.com/index.php [NC,L,R=301]或者没有负前瞻,试着用通常的状态检查。请确保您一次只放置上述规则集或遵循规则集。
RewriteEngine ON
RewriteRule %{REQUEST_URI} !metaball [NC]
RewriteRule foobar http://www.example.com/index.php [NC,L,R=301]发布于 2021-04-08 10:40:00
您可以使用负前瞻模式
RewriteRule ^(?!.*meetball).*foobar http://www.example.com/index.php [L,R=301]如果在URI中的任何地方都可以找到(?!.*meetball),那么meatball就会导致模式匹配失败。此外,没有必要使用分组,因此在我的回答中删除了(...)。
https://stackoverflow.com/questions/67002259
复制相似问题