A common question that comes up when people are using or evaluating the Url Master module is 'how can I do a 301 redirect from /default.aspx to my site root?'. There's a forum thread on it the Url Master forum.
All along I have maintained a certain lack of knowledge into the dark and mysterious depths of the way IIS handles incoming requests to the root path of a website. With the background din of requests related to this building to a soft roar, I decided to fully research the topic and see what I could do.
Why Redirect /default.aspx to the site root?
The fundamental problem is this : for many ASP.NET websites (and DotNetNuke based websites are particularly bad in this respect) there are multiple Urls in which the home page can be found.
On an ordinary ASP.NET site, you will find:
www.domain.com/default.aspx
and
www.domain.com
These two Urls will bring up the same page of content, yet will be indexed by Search Engines as two separate Urls. The same thing will happen if you're using index.htm, index.asp, index.aspx or any other 'default' document. You might only see one of the Urls in the search index, but that's probably because the other doesn't rank as well. Effectively, you're looking at a duplicate content problem.
Try it out : check your site for www.domain.com and www.domain.com/default.aspx - and check out (using the Google Toolbar) the PageRank (PR) for each - I bet the PR is different.
Essentially duplicate content problems mean that the 'link juice', or total value of all the incoming links for your site, is split between two urls, effectively giving each half as much value.
With DotNetNuke and the myriad of standard Url naming schemes, you can add to that list:
www.domain.com/default.aspx?tabid=36 (assuming tabid 36 is the home page)
www.domain.com/home/tabid/36/default.aspx
www.domain.com/tabid/36/default.aspx
www.domain.com/home.aspx
For DNN users, that makes a total of 6 different possibilities for the one page. Not just duplicate content, but sixplicate content!
What the Url Master module does
If you're running the Url Master module, you've essentially fixed most of the problem. This is because it will automatically redirect all of the various DNN Urls back to the site root. This is built in to the module : you don't have to switch anything on.
However, for the majority of users, one pesky duplicate Url remains : the /default.aspx. I've tried to sort it out, and the problem is this. If you do a 301 (or 302) redirect from www.domain.com/default.aspx to www.domain.com, IIS will take that incoming request url (www.domain.com), and then stick the /default.aspx (as your configured 'default' document in the IIS configuration for your site) onto the end, effectively ending up with a Url that looks like www.domain.com/default.aspx to ASP.NET. Note, the user will not see the /default.aspx - it's the internal Url value that is affected, not the address typed into the browser bar. However, when the module sees the new request coming in, then it will strip the /default.aspx off the end and redirect back to www.domain.com. And then IIS will put the /default.aspx back on, the Url Master module will take it off, IIS puts it back on - a comedy slapstick of duelling programs thus begins. Only it's not so funny for the browser, who is sitting there wondering why the site won't come up. Unless they are using Firefox, which is smart enough to say 'hey, you two programs, stop it!' - and breaks the redirect loop and tells you about it.
I worked out what causes the /default.aspx to be tacked onto the end of the request in some cases, and not in others. It's the extension mapping in the IIS configuration settings. If you run a wildcard extension (like this site does), then IIS doesn't put the /default.aspx onto the end of the request. So, presto, you can remove it without getting into a terminal redirect loop. This is why you can request the /default.aspx version of www.ifinity.com.au, and it will redirect back to the site root.
If you aren't running wildcard extensions in IIS (and the majority of people do not) then you're stuck. There's an option in the Url Master 'Friendly Url Settings' page called 'do redirect for /default.aspx' - you have to have this turned off unless you are running wildcard extensions on your site. This setting effectively stops the program getting into a terminal loop with IIS.
How to solve your default.aspx Redirect problems
Here's the news you don't want to hear: you can't solve it from a server point of view without changing your web server. I haven't determined whether IIS7 is afflicted yet, but for IIS5/6, you're stuck.
What you can do to work with the problem:
- don't use the www.domain.com/default.aspx Url anywhere in your site, ever. If you don't use it, it won't get indexed. If you're running DotNetNuke, you've got a bit of a problem because the standard 'Logo' skin control automatically generates a home-page hyperlink with, you guessed it, /default.aspx on the end. My suggestion: bake your logo into your skin and forget the logo skin control.
- search around for anyone linking to your site with the /default.aspx url, and if you can, beg them to change it to the standard site root www.domain.com version.
- prevent anyone linking to the /default.aspx version by client redirecting. A client redirect is a javascript based redirect. Search engine bots won't process a client-based redirect, but if the /default.aspx Url never appears in the address bar, then it should never get bookmarked or linked by anyone else. This article shows how to put in a javascript based client redirect : http://oyoy.eu/huh/redirect-default-aspx-asp-net/
You could incorporate that Javascript into your home page via some Html. It's not the prettiest solution, but it would solve (half) the problem.
Will the Url Master module ever solve this problem?
Never say never, but in the short term : no. Unless someone comes up with a smart way of handling it at the server end and is gracious enough to tell me how, the present situation will stand. If you're that smart person with some insight, please share via the comments below.