简体   繁体   中英

IIS redirect rule not working

<rule name="Directories The" stopProcessing="true">
    <match url="^Directories/The" />
    <action type="Redirect" url="/" />
</rule>`

I have two url like this www.mydomain/Directories/the and www.mydomain/Directories/the-hindu. But i only want to redirect first url only. If i put above code two urls are redirecting.

I tried with exact match and wild card also not working. I dont want www.mydomain/Directories/the-hindu to my home page

`

The problem is that your regexp ^Directories/The is matching for both URLs:

  • www.mydomain/Directories/the
  • www.mydomain/Directories/the-hindu

You need to add the end of string condition to your regexp. The correct rule should be:

<rule name="Directories The" stopProcessing="true">
    <match url="^Directories/The$" />
    <action type="Redirect" url="/" />
</rule>`

And this rule will match only www.mydomain/Directories/the

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