Friday, April 27, 2012

Fix 5 Common SEO problems using URLRewrite module and Web.config

There are an example code used to fix top 5 common problems for SEO, to get unique urls, improve ranking on Search Engine likes Google, Bing, Yaoo

This example is run on example.com

<rewrite>
                <rules>
                    <!--Fix 5 Common SEO problems using URLRewrite module and Web.config-->
                    <rule name="No-slash to slash">
                        <match url="http://example.com"/>
                        <action type="Redirect" url="http://example.com/" redirectType="Permanent"/>
                    </rule>
                    <rule name="www to non-www">
                        <match url="(.*)"/>
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^example\.com$" negate="true"/>
                        </conditions>
                        <action type="Redirect" url="http://example.com/{R:1}" redirectType="Permanent"/>
                    </rule>
                    <rule name="No Default.aspx" stopProcessing="true">
                        <match url="(.*?)/?Default\.aspx$"/>
                        <action type="Redirect" url="{R:1}/" redirectType="Permanent"/>
                    </rule>
                    <rule name="No .aspx" stopProcessing="true">
                        <match url="(.*?)\.aspx$"/>
                        <action type="Redirect" url="{R:1}.html" redirectType="Permanent"/>
                    </rule>
                    <rule name="Lower Case URLs" stopProcessing="true">
                        <match url="[A-Z]" ignoreCase="false"/>
                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                            <add input="{URL}" pattern="WebResource.axd" negate="true"/>
                        </conditions>
                        <action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent"/>
                    </rule>

                    <!--End Fix 5 Common SEO problems using URLRewrite module and Web.config-->
                </rules>
            </rewrite>

Place at between:
<system.webserver>
....
</system.webserver>


Lai

No comments:

Post a Comment