0

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
AskMe
  • 2,495
  • 8
  • 49
  • 102
  • 1
    Here it is : https://stackoverflow.com/questions/10399932/setting-up-redirect-in-web-config-file – AskMe Aug 02 '21 at 17:58
  • A 301 redirect essentially means "Moved Permanently" as an HTTP status code and will be recognised for SEO purposes. https://stackoverflow.com/questions/48886601/how-to-properly-make-301-redirect – David Tansey Aug 03 '21 at 00:22

1 Answers1

0

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:

<html>
    <head>
        <meta http-equiv="refresh" content="0; url=https://www.google.com" /> 
    </head>
    <body>
    </body>
</html>
Bryan Trach-MSFT
  • 765
  • 1
  • 5
  • 9