Home > other >  " " character causing issues in IIS URL rewrite
" " character causing issues in IIS URL rewrite

Time:09-23

I have the URL that I want to set a redirect to in IIS.

Current URL: portal/en_us/apps/app doc

New URL: apps/newapps

Not working with

<rule name="From portal/en_us/apps/app doc" stopProcessing="true">
    <match url="^portal/en_us/apps/app doc$" ignoreCase="true" />
    <action type="Redirect" url="https://domain1123.com/apps/newapps" />
</rule>

results in a 404 error

CodePudding user response:

Referring to a reference guide, we'll see that is defined as working like this:

Matches previous element one or more times.

That means that this expression:

^portal/en_us/apps/app doc$

Will match an entire string containing:

  • portal/en_us/apps/appdoc
  • portal/en_us/apps/apppdoc
  • portal/en_us/apps/appppdoc
  • portal/en_us/apps/apppppdoc

And so on.

To actually match a literal , you need to escape it using \:

^portal/en_us/apps/app\ doc$

Now it is treated as a literal and not interpreted as "one or more p characters".

CodePudding user response:

You can try to encode the " " character first, and then redirect.

You can use this link to code: https://www.urlencoder.org.

  • Related