The following rewrite rule redirects requests to domain pointers of a Web site to the Web site's URL. This is required to rewrite the URL in the address bar of the browser requesting the domain pointers. The rule preserves the sub-domain requested and the document path.
<rewrite> <rules> ...
<rule name="Redirect domain pointers to example.com" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="true"> <add input="{HTTP_HOST}" pattern="example\.com$" negate="true" /> <add input="{HTTP_HOST}" pattern="^((.*\.)?).*\.com$" /> </conditions> <action type="Redirect" url="http://{C:1}example.com/{R:1}" redirectType="Permanent" /> </rule>
... </rules> </rewrite>
Usage: Replace the tokens 'example' and 'com' as required and copy and paste the rewrite rule to the <system.webServer> section of the Web site's Web.config file.
Examples: Request to example.net (domain pointer) resolves to example.com (Web site). Request to example.net/path (domain pointer/path) resolves to example.com/path (Web site/path). Request to sub.example.net (sub-domain.domain pointer) resolves to sub.example.com (sub-domain.Web site). Request to sub.example.net/path (sub-domain.domain pointer/path) resolves to sub.example.com/path (sub-domain.Web site/path).
|