Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS 7 Multiple Domain Home Page Canonical Redirect

In our web.config file we control 6 different international domains.

How do we do the following with 1 rule:

Redirect

  • www.1of6Domains.com/index.htm
  • www.1of6Domains.com/index.html
  • www.1of6Domains.com/default.asp
  • www.1of6Domains.com/default.aspx

to

  • www.1of6Domains.com

Something like this?

<rule name="Canonical Redirect" enabled="true" stopProcessing="true">
    <match url="(.*)/(index.html|index.htm|default.asp|default.aspx)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
    <action type="Redirect" url="{R:1}" />
</rule>
like image 470
Brent Avatar asked Nov 13 '22 15:11

Brent


1 Answers

I would go with:

<rule name="Canonical Redirect" enabled="true" stopProcessing="true">
    <match url="^index.html$|^index.htm$|^default.asp$|^default.aspx$" />
    <action type="Redirect" url="/" />
</rule>

If by saying www.1of6Domains.com you mean each domain might be different then action must be (bear in mind that it assumes non https traffic): <action type="Redirect" url="http://www.1of6Domains.com" />

EDIT: Here are the rules to handle multiple domains (it's possible with one rule, but rewrite map would need to be created, not sure you want that complication):

<rule name="Canonical Redirect Non Https">
    <match url="^index.html$|^index.htm$|^default.asp$|^default.aspx$" />
    <action type="Rewrite" url="http://{HTTP_HOST}/" />
    <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
    </conditions>
</rule>

<rule name="Canonical Redirect Https">
    <match url="^index.html$|^index.htm$|^default.asp$|^default.aspx$" />
    <action type="Rewrite" url="https://{HTTP_HOST}/" />
    <conditions>
        <add input="{HTTPS}" pattern="^ON$" />
    </conditions>
</rule>
like image 77
Tomek Avatar answered Jan 04 '23 02:01

Tomek