Welcome to WebmasterWorld Guest from 18.206.48.142

Forum Moderators: ocean10000

Message Too Old, No Replies

URL Canonicalization for Windows IIS

     
1:08 pm on Dec 15, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 26, 2008
posts:90
votes: 0


Dear Webmasters,

Recently i have register a domain and space in Go daddy under "Windows Plan".

Now my question is I want to solve "URL Canonicalization Issues for my domain".

What are steps to do to avoid the "canonicalization problem"?

I know to solve this issues by creating a permanent redirection using 301 redirect in .htaccess for Linux server.

But how to do with Windows Server.

Thanks in Advance

12:25 am on Dec 16, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11823
votes: 236


ISAPI_Rewrite is the equivalent for IIS
6:00 am on Dec 16, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:733
votes: 0


If GoDaddy don't have ISAPI_Rwrite on their servers, you can ask if they have the IIS7 Rewrite Module [iis.net] installed.

If this is also not the case you can implement your own simple redirect method within the BeginRequest method in the Global.asax.

8:23 am on Dec 16, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:733
votes: 0


Here is a simple example of doing it from the Global.asax file:

void Application_BeginRequest(object sender, EventArgs e)
{
if (!HttpContext.Current.Request.Url.AbsoluteUri.ToLower().StartsWith("http://www."))
{
string newUrl = HttpContext.Current.Request.Url.AbsoluteUri.ToLower().Replace("http://", "http://www.");
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", newUrl);
}
}
10:14 am on Dec 16, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11823
votes: 236


how do you solve the default directory index document canonicalization problem without ISAPI_Rewrite?
http://example.com/index.html
11:29 am on Dec 16, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:733
votes: 0


how do you solve the default directory index document canonicalization problem without ISAPI_Rewrite?

With the IIS7 rewrite module:

<rule name="Default Document" stopProcessing="true">
<match url="(.*)default.aspx"/>
<action type="Redirect" url="{R:1}" redirectType="Permanent"/>
</rule>

11:41 pm on Dec 16, 2009 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member dstiles is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:May 14, 2008
posts: 3272
votes: 19


A simple way on any system is the canonical tag. Although it's better if you can get it right in the source code, you cannot force linking sites to get it right so I use both.

<link rel="canonical" href="http://www.example.com/" />

The href can be any reasonable url including querystrings.

2:20 am on Dec 17, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11823
votes: 236


the canonical link element is a bandaid to be used as a last resort.
it is only available to those who look at source code.
it is useful only for the search engines that support it in their indexing, should they decide to follow it.
it is a hint for search engines and not a directive.
it does absolutely nothing for user agents.
it does nothing to discourage people from linking to the non-canonical url when you serve up a non-canonical url.

canonical: reduced to the simplest and most significant form possible without loss of generality

the "canonical solution" is to provide a 301 redirect to the canonical url, in which case the link element is redundant.

11:38 pm on Dec 17, 2009 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member dstiles is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:May 14, 2008
posts: 3272
votes: 19


I did say it was better if it could be fixed in the source. :)

On the other hand, it does seem to help my sites to get garbled URLs homogenized by SEs.

11:50 pm on Dec 17, 2009 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member ogletree is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 14, 2003
posts:4319
votes: 42


With IIS you have to enforce capitalization since IIS will show the same content for upper and lower case URL's. I asked Matt Cutts one time if making sure the whole site used lower case was a good idea and he said yes.
5:55 am on Dec 18, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:733
votes: 0


Fortunately, there is also a method for this with the rewrite module:

<rule name="Convert to lower case" stopProcessing="false">
<match url=".*[A-Z].*" ignoreCase="false"/>
<conditions>
<!-- The following condition prevents rule from rewriting requests to .axd files -->
<add input="{URL}" negate="true" pattern="\.axd$"/>
</conditions>
<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent"/>
</rule>
9:49 am on Jan 5, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2004
posts:1992
votes: 74


-- how do you solve the default directory index document canonicalization problem without ISAPI_Rewrite? --

One method I used in the past was to rename the default.aspx to anyfilenamewhatever.aspx and set that file/default document as first on the list on Documents Tab in IIS.

Then never link to that file in the code.

No one can link-to/try-to-hack the file if they don't know the name of the file, no matter wHat cASe iT's in, right?

11:09 am on Jan 5, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:733
votes: 0


One method I used in the past was to rename the default.aspx to anyfilenamewhatever.aspx and set that file/default document as first on the list on Documents Tab in IIS.

This is also a good option, just make sure that the form action= doesn't point to the filename. You can change that with:

Form1.Action = "/path/to/page/";
* this only works with ASP.net 3.5 SP1
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members