Tip/Trick: Fix Common SEO Problems Using the URL Rewrite Extension
page 6 of 11
by Scott Guthrie
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 35928/ 67

Try the Rule Out

Now that we’ve saved the rule, let’s try it out on our site.  Try the following two URLs on my site:



Notice that the first URL (which has a capital “A”) automatically does a redirect to a lower-case version of the URL. 

Scenario 3: Trailing Slashes

Another common SEO problem I discussed earlier in this post is the scenario of trailing slashes within URLs.  The trailing slash creates yet another situation that causes search engines to treat the URLs as different and so split search rankings:



We can fix this by adding a new IIS Rewrite rule that automatically redirects anyone who navigates to the first URL (that does not have a trailing slash) to instead go to the second one that does.  Like before, we will setup the HTTP redirect to be a “permanent redirect” – which will indicate to search engines that they should follow the redirect and use the new URL they are redirected to as the identifier of the content they retrieve. 

To create such a rule we’ll click the “Add Rule” link in the URL Rewrite admin tool again.  This will cause the “Add Rule” dialog to appear again:

The URL Rewrite admin tool has a built-in “Append or remove the trailing slash symbol” rule template. 

When we select it and click the “ok” button we’ll see the following dialog which asks us if we want to create a rule that automatically redirects users to a URL with a trailing slash if one isn’t present:


When we click the “OK” button we’ll get a pre-written rule that automatically performs a permanent redirect if the URL doesn’t have a trailing slash – and if the URL is not processed by either a directory or a file. 

Like within our previous lower-casing rewrite rule we’ll add one additional condition clause that will exclude WebResource.axd URLs from being processed by this rule.  This will avoid an unnecessary redirect for happening for those URLs.

This will save the following additional rule to our web.config file:

                <rule name="Default Document" stopProcessing="true"> 
                     <match url="(.*?)/?Default\.aspx$" /> 
                     <action type="Redirect" url="{R:1}/" /> 
                <rule name="Lower Case URLs" stopProcessing="true"> 
                     <match url="[A-Z]" ignoreCase="false" /> 
                     <conditions logicalGrouping="MatchAll"
                     <add input="{URL}" pattern="WebResource.axd" negate="true" /> 
                     <action type="Redirect" url="{ToLower:{URL}}" /> 
                <rule name="Trailing Slash" stopProcessing="true"> 
                     <match url="(.*[^/])$" /> 
                     <conditions logicalGrouping="MatchAll"
                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory"
                              negate="true" /> 
                         <add input="{REQUEST_FILENAME}" matchType="IsFile"
                              negate="true" /> 
                     <add input="{URL}" pattern="WebResource.axd" negate="true" /> 
                     <action type="Redirect" url="{R:1}/" /> 

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-02-24 12:39:46 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search