chrr
chrr

Reputation: 320

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

Upvotes: 0

Views: 788

Answers (1)

Lost_Cause
Lost_Cause

Reputation: 96

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

Upvotes: 1

Related Questions