Search engine optimization (SEO) is very important for sites. Most of the traffic to the sites goes straight from the search engines, and improving the search relevance of your site will lead to an increase in users to the site. This may explicitly or implicitly increase revenue from the site.
This article will tell you how you can use the
Rewrite Extension URL to fix a bunch of common SEO problems your website may have. You need only 15 minutes and you don’t need to make any changes to the code in order to apply 4 simple
URL Rewrite rules for your site and attract more visitors and traffic from search engines. The following techniques work the same way on both ASP.NET Web Forms and ASP.NET MVC sites (and not even ASP.NET sites)
We measure the SEO level for your website using the Microsoft SEO Toolkit
A few months ago, I was
talking about the free SEO Toolkit. This useful tool allows you to automatically scan your site for compliance with SEO rules and notify you if problems have been found. I
highly recommend downloading and using this tool for any site you work with.
')
Below is a simple example of a report that I launched for one of my sites (
www.scottgu.com ) before applying the URL Rewrite rules, which I will talk about later:
![seo9_thumb_28660B78 [1] seo9_thumb_28660B78[1]](https://weblogs.asp.net/blogs/scottgu/seo9_thumb_28660B781_thumb_4601E342.png)
Search Relevance and URL Splitting
Two important things that rank search engines on your site for search relevance:
- How many other sites link to your content. Search engines look, if many people on the Internet link to your site, then it is considered successful, which means it must have a higher relevance.
- The uniqueness of the content on the site. If the search engines see that the content is duplicated on different sites or in different places on your site, then relevance should be reduced.
It should be very careful to deal with one important thing during the construction of the site, it is
forbidden to use different URLs for the same content on the site.
Especially, by allowing external sites to link to the same content using different links, you will get a division of link counting and page rank, which ultimately results in a lower page rank if you had a single URL, such a negative effect would be absent. Prohibiting external sites to link to you in various ways in theory sounds good, but what does it mean in practice, how to avoid it?
4 real common SEO problems your website may have
Below I will list 4 examples of the most common problems that may inadvertently arise and lead to different links to the same content.
Problem # 1: Default Document
IIS (and other web servers) support the concept of a “document by default”. This avoids the explicit indication of the page that you want to view in the root of the website or in its subdirectories. Agree - it is convenient, but this means that by default the content is available at two different public addresses, but this is already bad. For example:
http://scottgu.com/
http://scottgu.com/default.aspx
Problem number 2: Register of characters in the URL
Web developers often do not think that the URL for search engines is case-sensitive. And this means that search engines work with the specified links, as with two completely different URLs:
http://scottgu.com/Albums.aspx
http://scottgu.com/albums.aspx
Problem number 3: Slash there, slash here
Looking at the links below, they look the same, but it was not there - they are completely different. Slash at the end creates another situation where search engines view these links as different:
http://scottgu.com
http://scottgu.com/
Problem # 4: Basic Addresses
Sometimes websites support two treatment options, with and without the “www” prefix. And in this case, the URLs are considered completely different:
http://scottgu.com/albums.aspx/
http://www.scottgu.com/albums.aspx/
How to easily fix the listed problems in 10 minutes using IIS Rewrite
If you were careless during the creation of the site, then guaranteed to make one of these errors. Fixing these problems will improve search engine rankings and drive more traffic to your site.
The good news is that these 4 problems are fixed with the
URL Rewrite Extension . This is a
completely free extension from Microsoft for IIS 7.x (on Windows Server 2008 / R2, Windows Vista / 7). And now the news is even better - you do not have to change the code in your application.
You can easily install the
Rewrite Extension URL in 3 minutes using the
Microsoft Web Platform Installer (a free tool that automatically configures the web server and the development machines). Just click on the green “Install Now” button on the
Rewrite Spotlight URL page to install on your machine:

Having installed the add-on, its icon will immediately appear in the IIS 7 Admin Tool:

Double clicking on the icon will open the URL Rewrite administrative panel, which will display the list of URL Rewrite rules defined for applications and sites:

Please note that there are no rules in the list immediately. We can click “Add Rule” in the upper right corner of the panel to add new URL Rewrite logic for our site.
Example # 1: Processing the default document version
One of the SEO issues that we discussed earlier in this article is the “default document”:
scottgu.com
http://scottgu.com/default.aspx
We can fix it by adding a new IIS rewrite rule that automatically
redirects anyone who contacts the second address to the first address. We will set the HTTP redirect as permanent, which will require the search engines to follow the new address and use this address as an identifier for the content they received.
Let's look at how to create this rule. Start by clicking “Add Rule”, as shown below:

We will select the “Blank Rule” template in the “Inbound rules” group to create a new custom URL Rewrite rule. And then we will see an empty panel:

Don't worry, setting up a rule is very simple. The following 4 steps will explain how to do this:
Step # 1: Name for the rule
The first step is to set a name for the rule. A reasonable name should be given to easily navigate the list later. Let's call this rule “Default Document URL Rewrite”:

Step # 2: Set up a regular expression that matches this rule
Our second step is to set a regular expression filter that will be run when the incoming URL matches the pattern. Do not worry if you are not strong with regular expressions - I am not friends with them either. You need to find someone who is friends with them or copy from other sites.
Below we will set the required regular expression:
(. *?) /? Default \ .aspx $
This template will work with URLs that end in Default.aspx. "(. *?)" matches the preceding characters zero or more times. “/?” Says a slash may be present or vice versa. The “$” character at the end allows you to make sure that the rule will be applied to strings that necessarily end with Default.aspx.
Combining all the elements of a regular expression we get a working rule not only for the root of the website (
http://scottgu.com/default.aspx ), but also for other subdirectories of the site (
http://scottgu.com/photos/default.aspx ). Since the “ignore case” checkbox is checked, both versions of the “Default.aspx” and “default.aspx” addresses will work.

One of the nice built-in functions is the ability to test the pattern - “Test pattern”:

Above, I added the address “products / default.aspx” and clicked “Test”. We immediately got the result of the execution of the rule with respect to this URL.
Step 3: Installing a permanent redirect
Next, set up an action that matches the regular expression for the incoming URL:

Above, I have set the action “Redirect” to the “Action Type” drop-down list. “Redirect Type” will be HTTP 301 Permanent Redirect, which ensures that search engines will follow the redirect.
I also set the property “Redirect URL”:
{R: 1} /
It means that we want to redirect the web client request to a new URL, throwing the last part of the “Default.aspx” from the original URL. For example, for the request
http://scottgu.com/default.aspx the redirection will be on
http://scottgu.com/ , and for
http://scottgu.com/photos/default.aspx it will be
http://scottgu.com / photos / .
The construction of the regular expression “{R: N}”, where N> = 0, is called the reciprocal link, where N is the index of the reciprocal link. In the case of our template "(. *?) /? Default \ .aspx $", if the incoming URL is "products / Default.aspx", then {R: 0} will contain "products / Default.aspx", and { R: 1} - "products". We are going to use the value {R: 1} where we will redirect users.
Step 4: Save and apply the rule
The final step is to click the “Apply” button in the upper right corner of the IIS administration panel, which will save the Rewrite URL rule in the web.config for all root directories of our applications (in the <system.webServer / rewrite> section):
< configuration >
< system.webServer >
< rewrite >
< rules >
< rule name ="Default Document" stopProcessing ="true" >
< match url ="(.*?)/?Default\.aspx$" />
< action type ="Redirect" url ="{R:1}/" />
</ rule >
</ rules >
</ rewrite >
</ system.webServer >
</ configuration >
Since IIS 7.x and ASP.NET work with the same web.config files, you can actually copy and paste the above code into your web.config file using Visual Studio and you don’t need to configure everything through the administrative panel . And now it is even easier to add and deploy URL Rewrite rules with ASP.NET applications.
Step 5: Test the rule
Now that we’ve saved the rule, let's test it. Try the following links for my site:
http://scottgu.com/
http://scottgu.com/default.aspx
Noticed that the second link automatically redirects to the first.
Example 2: Register of characters in a URL
Another common problem that we talked about above is
the case sensitivity of search engines. Which means that the search engine will separately consider the ranking for both links:
http://scottgu.com/Albums.aspx
http://scottgu.com/albums.aspx
We can fix this by adding a new IIS rewrite rule that
automatically redirects anyone who links to the first link to the second. As before, we set HTTP redirection as permanent:
To create a rule, click again the “Add Rule” button in the URL Rewrite admin panel:

Unlike the previous situation where we created the “Blank Rule”, we will use the built-in rule template “Enforce lowercase URLs”. When we click “ok”, we will see the following dialog, which will ask to confirm our intentions:

After clicking “Yes”, we will get a ready-made rule that automatically performs a permanent redirect if the incoming URL contains capital letters on the URL with full capital letters:

We can save the rule without changing anything by clicking the “Apply” button and apply it to all incoming URLs.
Since my website
www.scottgu.com uses ASP.NET Web Froms, I have to make small changes to the above rule by adding a condition that excludes the “WebResource.axd” handler built into ASP.NET. The URL for the WebResource.axd handler will only come from the server controls on my pages and never from external sites.
The good news is that adding a condition that disables the URL Rewrite rule for some URLs is very simple. We only need to expand the “Conditions” group in the form:

Next, click the “Add” button:

Above, I entered {URL} in the Condition field, indicating that the rule should be executed only when the URL does not match the condition of the regular expression that checks for the presence of “WebResource.axd” in the string. This ensures that all requests to WebResource.axd will pass directly, without throwing me at the URL in lower case.
Note that if you already have static resources on your site, such as .jpg, .css, and .js files that have uppercase letters in the name, then you most likely want to add conditions that also cancel the URL redirection in lower case. Even if you do not add these rules, the site will function perfectly, but for internal resources there is no need for additional redirection in lower case, so it’s better to add such rules.When I click the "ok" button and apply a lower case rule, the admin panel will save the new rule to our web.config file:
< configuration >
< system.webServer >
< rewrite >
< rules >
< rule name ="Default Document" stopProcessing ="true" >
< match url ="(.*?)/?Default\.aspx$" />
< action type ="Redirect" url ="{R:1}/" />
</ rule >
< rule name ="Lower Case URLs" stopProcessing ="true" >
< match url ="[AZ]" ignoreCase ="false" />
< conditions logicalGrouping ="MatchAll" trackAllCaptures ="false" >
< add input ="{URL}" pattern ="WebResource.axd" negate ="true" />
</ conditions >
< action type ="Redirect" url ="{ToLower:{URL}}" />
</ rule >
</ rules >
</ rewrite >
</ system.webServer >
</ configuration >
We are testing the rule
Now that we’ve saved the rule, let's try it out on our site. Try the following links:
http://scottgu.com/Albums.aspx
http://scottgu.com/albums.aspx
Notice that the first URL, which has the capital letter “A”, automatically flips to the lower case URL.
Example 3: Slash at the end
Another common SEO problem I mentioned was a slash at the end of URLs. The slash at the end creates another situation where the search engine regards the URL as two different:
http://scottgu.com
http://scottgu.com/
We can fix this by adding a new IIS Rewrite rule that
automatically redirects anyone who clicks the first link (which does not have a slash at the end) to the second. As before, we will set HTTP redirection as permanent:
To create a rule, click again the “Add Rule” button in the URL Rewrite admin panel:

The URL Rewrite administration tool contains a ready-made rule template “Append or remove the trailing slash symbol”.
Next, a dialog box will appear asking us if we want to create a rule that will automatically redirect users to a URL with a slash at the end if it is not in the address:

After clicking on “OK” we get a ready-made rule.
As with the previous lower case rule, we will add an additional condition that excludes the WebResource.axd address from the rule. As a result, in the web.config file we get:
< configuration >
< system.webServer >
< rewrite >
< rules >
< rule name ="Default Document" stopProcessing ="true" >
< match url ="(.*?)/?Default\.aspx$" />
< action type ="Redirect" url ="{R:1}/" />
</ rule >
< rule name ="Lower Case URLs" stopProcessing ="true" >
< match url ="[AZ]" ignoreCase ="false" />
< conditions logicalGrouping ="MatchAll" trackAllCaptures ="false" >
< add input ="{URL}" pattern ="WebResource.axd" negate ="true" />
</ conditions >
< action type ="Redirect" url ="{ToLower:{URL}}" />
</ rule >
< rule name ="Trailing Slash" stopProcessing ="true" >
< match url ="(.*[^/])$" />
< conditions logicalGrouping ="MatchAll" trackAllCaptures ="false" >
< add input ="{REQUEST_FILENAME}" matchType ="IsDirectory" negate ="true" />
< add input ="{REQUEST_FILENAME}" matchType ="IsFile" negate ="true" />
< add input ="{URL}" pattern ="WebResource.axd" negate ="true" />
</ conditions >
< action type ="Redirect" url ="{R:1}/" />
</ rule >
</ rules >
</ rewrite >
</ system.webServer >
</ configuration >
We are testing the rule
Now that we have a rule ready, let's test it:
http://scottgu.com
http://scottgu.com/
Notice that the first URL (which has no slash at the end) automatically jumps us to the URL about the slash at the end. Since the redirect is permanent, search engines follow the new URL and update the page rank.
Example 4: Basic Addresses
And finally, the last problem in SEO, the option when the site works with two versions of the URL with the “www” prefix and without:
http://www.scottgu.com/albums.aspx
http://scottgu.com/albums.aspx
We can fix this by adding an IIS rewrite rule that automatically redirects anyone who follows the first link (with the “www” prefix) to the second. And again the redirection will be permanent.
To create a rule, click again the “Add Rule” button in the URL Rewrite admin panel:

The URL Rewrite administration tool contains a ready-made rule template “Canonical domain name”.
Next, the dialog box that appears asks us whether we want to create a rule that will automatically redirect users to the primary URL:

Above, I entered the primary address I want to use for the web: scottgu.com. After clicking on “OK” we will get a ready-made rule in the web.config file:
< configuration >
< system.webServer >
< rewrite >
< rules >
< rule name ="Cannonical Hostname" >
< match url ="(.*)" />
< conditions logicalGrouping ="MatchAll" trackAllCaptures ="false" >
< add input ="{HTTP_HOST}" pattern ="^scottgu\.com$" negate ="true" />
</ conditions >
< action type ="Redirect" url ="http://scottgu.com/{R:1}" />
</ rule >
< rule name ="Default Document" stopProcessing ="true" >
< match url ="(.*?)/?Default\.aspx$" />
< action type ="Redirect" url ="{R:1}/" />
</ rule >
< rule name ="Lower Case URLs" stopProcessing ="true" >
< match url ="[AZ]" ignoreCase ="false" />
< conditions logicalGrouping ="MatchAll" trackAllCaptures ="false" >
< add input ="{URL}" pattern ="WebResource.axd" negate ="true" />
</ conditions >
< action type ="Redirect" url ="{ToLower:{URL}}" />
</ rule >
< rule name ="Trailing Slash" stopProcessing ="true" >
< match url ="(.*[^/])$" />
< conditions logicalGrouping ="MatchAll" trackAllCaptures ="false" >
< add input ="{REQUEST_FILENAME}" matchType ="IsDirectory" negate ="true" />
< add input ="{REQUEST_FILENAME}" matchType ="IsFile" negate ="true" />
< add input ="{URL}" pattern ="WebResource.axd" negate ="true" />
</ conditions >
< action type ="Redirect" url ="{R:1}/" />
</ rule >
</ rules >
</ rewrite >
</ system.webServer >
</ configuration >
We are testing the rule
Now that we have a rule ready, let's test it:
http://www.scottgu.com/albums.aspx
http://scottgu.com/albums.aspx
Please note that the first address (with a “www” prefix) automatically takes you to the second URL, which has no prefix.
4 simplest rules for improving SEO
Simply use the four SEO rules listed above and setting them up should take a maximum of 15 minutes for existing sites.
The beauty of using a solution such as URL Rewrite Extension is that you do not need to change any code of your application or break the work of already existing links to the site. Users who visit the site using old links will be automatically redirected to new URLs. And the search engines will begin to issue an increased rating, which will lead to raising your site in positions.
Changing your URL rewrite rules in the future is quite simple by editing the web.config file or using the IIS 7.x administration panel:

Clicking on any rule will open an editor that will help you change and save any rule.
Results
Every developer wants to improve SEO for their public sites. If you have not already done so, download the
SEO Toolkit and analyze your site today.
New URL routing features in ASP.NET MVC and
ASP.NET Web Forms 4 make it even easier to build applications and get even more control over URLs. Tools such as the
URL Rewrite Extension , which we talked about, help in a simple way to improve URLs that are already found in the public domain on your and external sites, without requiring any changes in the code.
The Rewrite Extension URL provides much more than just SEO, which I will cover in the following articles.