Reputation: 519
I have a site, that has aliases:
site1.com
site2.com
site3.com
But they are all the same site.
I need the rules for asp.net, that will allow site3.com & site2.com to redirect to www.site1.com with status 301
Upvotes: 1
Views: 1334
Reputation: 342
I recommend using the URL Rewrite module in IIS to redirect these requests. Something like this might work (though this may need tweaking)...
<rewrite>
<rules>
<rule name="CanonicalHostNameRule1" stopProcessing="true">
<match url="site?.com" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.site1.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.site1.com/" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
EDIT - Forgot to include the redirectType attribute
Upvotes: 2
Reputation: 1309
I think a better option is to set these things in IIS. In IIS7 you can create a site (or even a virtual dir) for the unwanted domains, then in the 'HTTP redirect' section you can set the destination and your desired HTTP status code.
If for some reason you cannot do this via IIS try searching SO for coded solutions: https://stackoverflow.com/search?q=asp.net+301+redirect
Upvotes: 0