简体   繁体   中英

IIS rewrite rule - invalid rule

I'm trying to convert some mod_rewrite rules to IIS 7.5 rules in my web.config

I'm having a problem with the following as IIS gives the error of -

"The expression "^(?!/(___generated|images)/.*$)" contains an escape sequence that is not valid."

The rule is:

<rule name="Imported Rule 2" stopProcessing="true">
  <match url="^(.*[A-Z].*)$" ignoreCase="false" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="(.*)" ignoreCase="false" />
    <add input="{URL}" pattern="^(?!/(\_\_\_generated|images)/.*$)" ignoreCase="false" />
  </conditions>
  <action type="Redirect" redirectType="Permanent" url="http\://{C:1}{R:1}" />
</rule>

Any help would be appreciated and yes I need to brush up on my regex!

Thanks

Try to replace _\\_\\_ with underscores only. Underscore is not a special character and does not need to be escaped with a backslash.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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