Redirect rule in web.config

I looked into this Seems like a simple redirect in IIS using the web.config file because I have a similar situation, but the approach mentioned there doesn't seem to work for me.

I have a help section on a website that I want to redirect to a different location right now. The rest of the site should remain unchanged, which means that only the help / content section should force the user to navigate to another site:

device.domain.com/help

device.domain.com/help/version

Must make a request to

company.custhelp.com

But for example device.domain.com/api should work. This is what I have tried. If I test the template inside IIS it says it will work. What am I missing?

<system.webServer>  
  <rewrite>
    <rules>
      <rule name="Help Redirect" stopProcessing="true">            
        <match url="(.*)/help(.*)" ignoreCase="true" />
        <action type="Redirect" url="http://company.custhelp.com/" appendQueryString="false" redirectType="Permanent" />
      </rule>
    </rules>
  </rewrite>
  ...
</system.webServer>

      

+3


source to share


1 answer


The match url will try to match in the path after the domain, starting at the moment of the forward slash. This is how it should be:

<match url="help(.*)" ignoreCase="true" />

      



The match url you wrote will match on device.domain.com/temp/help, but not on device.domain.com/help.

+3


source







All Articles