Redirection refers to the process of configuring a web server to redirect users from one location to a new site. There are several reasons why a user might want to redirect clients to a new location (such as from an http to a secure https connection, or if someone has moved a server URL to another server which require a redirect). To implement this URL redirection requires specific features to be installed at hosting servers like IIS, etc.
In IIS, there are two different ways by which we can implement this, 1. HTTP Redirect and 2. URL Rewrite.
However, if a user wants to redirect an existing URL to a new URL, and if the application URL formats are different (as below), then it becomes easier to implement this URL Rewrite.
To set this up simply follow the steps below…
Step 1: Open the IIS (Run > inetmgr) at “shoppingcm12.mycompany.com” hosting server and select the website “shoppingcm12. mycompany.com” from left menu. Please check if it contains the “URL Rewrite” icon or not as below.
If you don’t find this icon, please look to download the actual version file from the URL (https://www.iis.net/downloads/microsoft/url-rewrite) and install that at the server.
Step 2: Once the installation complete, please create a new Web.config file or use the exiting config file from the root hosting folder (as shown below) of shoppingcm12.mycompany.com website and copy the below code inside the <system.webServer> section of that Web.Config file,
<rewrite> <rules> <rule name="ApproveLinkRedirect" stopProcessing="true"> <!--match url="Shopping/ApproveLink.aspx" /--> <match url="^.*(?:Shopping/ApproveLink.aspx).*$" /> <conditions> <add input="{QUERY_STRING}" pattern="Approve=(\d+)" /> </conditions> <action type="Redirect" url="https://shopping.mycompany.com/Shopping/approver/approve?processingId={C:1}" redirectType="Permanent" appendQueryString="false" /> </rule> <rule name="RedirectAllRequests" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="false" pattern="" ignoreCase="true" /> </conditions> <action type="Redirect" url="https://shopping. mycompany.com" appendQueryString="false" /> </rule> </rules>
Finally, restart the IIS at the server and check the URL redirection.