I mentioned in a previous post about finding it harder to figure out redirects in web.config when compare to HTACCESS. I did figure out how to do a redirect in web.config and thought I should share.
I did a Google search and found many references. The best articles were Redirect Your URL Using IIS 7 and ASP.NET Web.config and IIS 7.0 and URL Rewrite, make your Web Site SEO.
It took a little trial and error but finally got my web.config to work. Here is a sample for reference.
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”Redirect for ML2″ stopProcessing=”true”>
<match url=”.*” />
<conditions>
<add input=”{HTTP_HOST}” pattern=”^ml2solutions.com$” />
</conditions>
<action type=”Redirect” url=”https://ml2solutions.com/{R:0}” redirectType=”Permanent” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>