Categories
code

Redirects in IIS – ASP.NET

While I am comfortable with working in Apache mod_redirect, Redirects on Windows IIS are a totally different animal. On a client’s project, I needed to implement a redirect on a Windows IIS server, using the DotNetNuke platform.

Here is how I did it

1. Look for the file named “SiteUrls.config” in the main root directory of the hosting environment.

2. Edit that file as follows:

<RewriterRule>
 <LookFor>.*PageThatNeedsToBeRedirected.aspx(.*)</LookFor>
 <SendTo>https://example.com/DestinationPage.php</SendTo>
 </RewriterRule>

3. Save the file and reload in the browser to verify that the redirect is occurring correctly.

This is it. You will need to replace “PageThatNeedsToBeRedirected” with the actual file name of the old path/file. Similarly, “DestinationPage” will be replaced by the page being redirected to.

 

By Amit Ramani

Ever heard of 'tech and tack' together in the same sentence? Chances are you did not. I am part owner of a 'tack' store in Wellington (TACKNRIDER), and full owner of a 'tech' firm(ANTERIK).

Leave a Reply

Your email address will not be published. Required fields are marked *