I have ASP.Net web application hosted in Azure App service.
I would like to redirect the URL to another URL from Web.config.
For example, the below urls
https://www.example.com/Products
and
https://example.com/Products
needs to be redirected to new url:
https://www.example.com/productregistration/ProductRegistration
and
https://example.com/productregistration/ProductRegistration
That is, when anyone hit this
https://www.example.com/Products
in the browser, it should to to
https://www.example.com/productregistration/ProductRegistration
How can I do this?
I tried this:
<rewrite>
<rules>
<rule name="example" stopProcessing="true" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="
https://www.example.com/Products" />
<add input="{URL}" pattern="^/$" />
</conditions>
<action type="Redirect"
url="https://www.example.com/productregistration/ProductRegistration"
redirectType="Temporary" />
</rule>
</rules>
</rewrite>
Getting error:
This page cannot be displayed because an internal server error has occurred.
And, where can I keep this in Web.config? Also, what is 301 redirection?
This redirect rule is not in the web.config but in the folder per se. It is an html redirect rule and you just need to go to the folder and add the following lines: