简体   繁体   English

Apache重写规则匹配一个条件但不匹配另一个条件

[英]Apache rewrite rule matching one condition but not matching another

I would like to rewrite everything that does not start with wp-content but ends in .html. 我想重写所有不以wp-content开头但以.html结尾的内容。 My failed attempt: 我失败的尝试:

 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_URI} !^/wp-content.*
 RewriteRule ^(.*)\.html /$1-pages/ [R=301,L]

You don't need RewriteCond here. 您在这里不需要RewriteCond Just modify next rule to: 只需将下一条规则修改为:

RewriteRule ^/?(?!wp-content/)(.*)\.html$ /$1-pages/ [R=301,L]

I used a negative lookahead to negate the results. 我使用否定的前瞻来否定结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM