Call Us 203.687.6053

Blog with a focus on DotNetNuke news, tips and tricks, DNN SEO, and insights and opinions about the DNN community at large.

Search Engine Friendly 301 Redirects Without Touching IIS

Posted by Tom on Friday, April 27, 2007 to DotNetNuke, SEO, Reviews, DNN Tips and Tricks

Most websites are configured to serve the same content (the home page) for www.mysite.com and mysite.com, but technically a web server could return two different pages for both urls. Why is this important? It could hurt your ranking and you are making Google and other search engines guess what page to index if there are numerous choices to choose from. Google calls this process of selecting one URL over another “canonicalization.”

So what can you do to ensure that Google picks your preferred URL?

For one, be consistent when forming your internal links. In other words, “don’t make half of your links go to http://example.com/ and the other half go to http://www.example.com” as renowned Google engineer Matt Cutts points out.

Secondly, implement a 301 permanent redirect from the non-www version of your site to the www version or vice versa, which is what I would like to focus on in this post.

While the web is full of examples on how to setup a 301 redirect on the all so popular Apache web server, IIS walkthroughs are rather scarce. And even if you do find them, most are on-page scripts that won’t solve the www vs. non-www dilemma and won’t work in DNN’s “one page” model.

Let’s say you want to permanently redirect the non-www version of your asp.net based website to the www version. The most straightforward way to do this in IIS is to actually set up two IIS web sites for your web site. Sounds confusing? See the screenshots below.

IIS Websites

Set up your www version as you would any other website. Include the www portion when entering the host header value and point to the DNN web files on your server.

IIS incluing www in host header

Now create a second IIS website and enter the host header value without www and point “the content for this resource” to your www URL like this:

IIS 301 permanent redirection

Notice the two variables ($S$Q) at the end of the URL, which ensure that all other pages besides the home page redirect correctly as well. Also make sure to have “the exact URL entered above” and “a permanent redirection for this resource” checked.

If everything went well, your browser will now redirect mysite.com to www.mysite.com. Another option is to install a component such as ISAPI_Rewrite, which emulates Apache's mod_Rewrite for IIS, but that’s food for another post.

Both of these approaches obviously require full IIS access, which is not an option in a shared hosting environment. But even with unrestricted IIS control, if I were to set up two IIS websites for every client on my web server, IIS would get messy very soon.

This leads us to the most elegant solution that does not involve IIS at all - UrlRewritingNet.UrlRewrite. With this open source component (HTTP module on steroids I guess) you upload a .dll into the bin directory of your website and add a few lines to web.config and you are done. Now you have a search engine safe redirect from mystite.com to www.mystite.com or vise versa without touching IIS. I’ve prepared a DNN 4.5.1 web.config with all three UrlRewritingNet.UrlRewrite settings in place for your reference. Download it here.

Best of all, this only scratches the surface of what UrlRewritingNet.UrlRewrite is capable of. With full regular expression support and the ability the plug in your own provider, the “rewrite opportunities” are endless. As an example, I’m currently trying to figure out how to shorten my permalink URLs, removing the tabid/53/articletype/articleview/articleid/xx/ part.

In closing, whatever method you prefer, make sure your redirects are configured correctly (301 and not 302) with a tool such as the Search Engine Friendly Redirect Checker.

As always, I appreciate your comments and if you like this post, then consider subscribing to my full feed RSS.


Permalink Permalink      Comments 70 Comments      RSS feeds RSS feeds      Email updates Email updates

 

Comments

Comment By vasilis on Friday, April 27, 2007 at 3:48 PM

wow, where did you have these ices hidden? :)

Great tips! Well done!

Comment By Tom Kraak on Friday, April 27, 2007 at 4:40 PM

Thanks. What are "ices" though?

Comment By Exiton on Saturday, April 28, 2007 at 6:25 AM

Doesn't work.

Says:

DotNetNuke Error: - Version 04.05.01

The type initializer for 'DotNetNuke.Data.DataProvider' threw an exception.

Comment By Tom Kraak on Saturday, April 28, 2007 at 8:13 AM

Are you sure all settings are in the right place in web.config?

Comment By Exiton on Saturday, April 28, 2007 at 9:16 AM

Well, I've found 3 pieces of settings and inserted them to the appropriate locations in my web.config file (also changed site address):

<!-- 1st UrlRewritingNet.UrlRewrite entry -->
<section name="urlrewritingnet" requirePermission ="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" />

<!-- 2nd UrlRewritingNet.UrlRewrite entry -->
<urlrewritingnet
rewriteOnlyVirtualUrls="true"
contextItemsPrefix="QueryString"
defaultPage = "default.aspx"
defaultProvider="RegEx"
xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >
<rewrites>
<add name="KickIt" virtualUrl="^http\://dotnetnukeru.com/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://www.dotnetnukeru.com/$1.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />
</rewrites>
</urlrewritingnet>


<!-- 3rd UrlRewritingNet.UrlRewrite entry -->
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />

Comment By Tom Kraak on Saturday, April 28, 2007 at 9:39 AM

And the .dll is in the bin folder?

Comment By Exiton on Saturday, April 28, 2007 at 10:00 AM

Yes, I did copy UrlRewritingNet.UrlRewriter.dll to the BIN folder.

Comment By Tom Kraak on Saturday, April 28, 2007 at 12:21 PM

Hmm, send your web.config to tom AT seablick DOT com and I'll take a look.

Comment By Exiton on Saturday, April 28, 2007 at 12:52 PM

Sent.

Comment By Tom Kraak on Saturday, April 28, 2007 at 8:47 PM

I found the problem. Totally my fault ... sorry about that. I put the 2nd UrlRewritingNet.UrlRewrite entry into the <connectionStrings> section. I fixed the download up in the post. Let me know how it goes.

Comment By Exiton on Saturday, April 28, 2007 at 8:51 PM

Yes, it's working now. Thank you very much! This "double address" thing annoyed me for some time already.

After I've uploaded new web.config I spent several minutes trying to determine whether rewriting is working or not, and could not find any difference. Then, all of a sudden, it indeed started working. I guess it may be a caching issue, or may be the functionality doesn't start working right away.

I have "friendly URLs" turned off by the way (if it has any difference).

I was wondering if it is also possible to redirect sitename.dz/<pagename> (or better yet <pagename>.sitename.dz) to www.sitename.dz/Default.aspx?tabid=<number>?

Comment By Tom Kraak on Saturday, April 28, 2007 at 9:09 PM

One thing at a time. dotnetnuke.ru and dotnetnukeru.com are pointing to the same website, right? If so, you should decide on a "primary" domain and redirect all "secondary" domains to that. See http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/
108/threadid/121507/threadpage/3/scope/posts/Default.aspx for more info on how to accomplish that.

Comment By green on Monday, April 30, 2007 at 8:42 AM

Thanks Tom, i really appreciate this tips, you are great.

Comment By xcentric on Monday, April 30, 2007 at 2:34 PM

So this tip only works if you have a dnn site without the www? Do I have that right? I just tried the web.config method and I get "Bad Request (Invalid Hostname)' from IIS. The IIS trick works fine. But as you said about creating 2 websites per client is too much work and messy. I have the three sections added but no go.

Comment By xcentric on Monday, April 30, 2007 at 2:35 PM

And I forgot to mention yes I have the dll in the bin folder.

Comment By Tom Kraak on Monday, April 30, 2007 at 2:42 PM

It works either way, no matter whether you prefer to redirect to non-www (like it do) or the other way around.

Not sure what you mean by "Bad Request (Invalid Hostname) from IIS" ... don't mix and match the two methods :)

Please clarify.

Comment By xcentric on Monday, April 30, 2007 at 2:53 PM

Curious also. Regarding IIS, wouldnt it be simpler to just add 2 host headers with and without the www in the same site? Does it not produce the same results as your IIS method?

Comment By Tom Kraak on Monday, April 30, 2007 at 2:58 PM

Doing that makes the site browsable as non-www and www, which is exactly what you don't want ... from an SEO perspective I mean.

Comment By xcentric on Monday, April 30, 2007 at 3:10 PM

Ok, I just did some more reading. I understand now the diference. Back to my problem. I dont have the methods mixed. What I meant about the error is that it is displayed when I request the non-www of the domain. The www still works but not without.

Comment By Tom Kraak on Monday, April 30, 2007 at 3:18 PM

And you do have both host headers specified? Hmm, I don't think I made that clear enough.

Comment By xcentric on Monday, April 30, 2007 at 3:23 PM

This is what I followed, "you upload a .dll into the bin directory of your website and add a few lines to web.config and you are done". So I need to add both host headers then?

Comment By Tom Kraak on Monday, April 30, 2007 at 3:29 PM

Yes, any domain and domain version (www and non-www) needs to have a host header entry. Sorry about that.

Comment By xcentric on Monday, April 30, 2007 at 3:53 PM

Ok. Its working. Thank you for your effort in helping me understand. Every little bit helps you know?

Comment By Tom Kraak on Monday, April 30, 2007 at 3:58 PM

It sure does. I'm glad you found it helpful.

Comment By Dax Davis on Tuesday, May 01, 2007 at 7:38 PM

It looks like this will not work on a DNN installation with multiple portals (so more then one domain). Am I correct?

Comment By Tom Kraak on Tuesday, May 01, 2007 at 7:44 PM

Multiple parent portals you mean?

I have not tested it, but I don't see why it would not work as you can specify multiple "KickIt" sections.

Comment By Exiton on Wednesday, May 02, 2007 at 12:41 AM

I have multiple portals installed and everything is working fine.

Comment By Dax Davis on Wednesday, May 02, 2007 at 6:31 PM

Multiple Kickit's. Sweet. Thanks, didn't think I could do that. Any reason this wouldn't work on a DNN 3.1.1 installation?

Comment By Tom Kraak on Wednesday, May 02, 2007 at 6:47 PM

It's compiled under .net 2.0. DNN 3.1.1 is .net 1.1.

Comment By Brian on Tuesday, May 15, 2007 at 12:04 PM

Outstanding!! Another tip, I needed this for ssl. Add another key for https: redirects and this goes even further...
thanks!

Comment By Tom Kraak on Tuesday, May 15, 2007 at 5:57 PM

Thanks Brian, good point. You might still get mixed content warnings in IE though with this approach.

Comment By Dax Davis on Wednesday, May 30, 2007 at 2:30 PM

Can anyone with powerful RegExp skills modify the KickIt string for so that any domain starting with www. gets forwarded to the non-www. url? e.g. Surf to www.mysite.com and it kicks you to mysite.com. I know how to modify it to do this explicitely:

<add name="KickIt" virtualUrl="^http\://www.mysite.com/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://mysite.com/$1.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />

But I would like to be able to put one line in here and have it do it for any and all domains on the DNN installation. I can then go an hand enter any exceptions.

Also, does this kickit line take into account any other URL or URL paramerters? I think it does.

Dax

Comment By Tom Kraak on Wednesday, May 30, 2007 at 2:46 PM

I'm not sure I follow you. You'll need to add multiple "KickIt" sections to accommodate multiple portals/domains on one DNN install.

Comment By Dax Davis on Wednesday, May 30, 2007 at 3:41 PM

yes, that is my understanding if I use the code above. But I would think that you can capture the domain using RegExp as well, so it does not need to be hard coded as it is in my example above.

So I would have a kicket that says any domain starting with www. will be changed to anydomain.com\etc\etc.... without the www.

Dax

Comment By Tom Kraak on Wednesday, May 30, 2007 at 4:07 PM

Hmm, not sure if that is supported. Did you check the documentation that came with the download?

You could also try asking about it on
http://groups.google.com/group/UrlRewritingNet

Comment By Shiraz Asif on Monday, June 11, 2007 at 6:09 PM

Hi Tom,

Thanks for this informative post. Actually I've been reading your posts for quite some time, and I find them to be amongst the most useful on the subject matter, so I wanted to pass on my thanks for sharing your insight. We tried it on a site of ours with some interesting results. I was hoping you can point me in the right direction:

1) The first problem is with the non-www to www redirect. Copying the settings from the blog example file leads to an application error.
I believe this has to do with the friendly URL module (HREF Exchanger from Inventua) we are using.
After some tweaking of the rule in UrlRewrite, the output URL ends up being something like default.aspx?tabid=xx. Is there a way to tweak the settings so that URL gets outputted in human friendly format?

2) The second problem is redirecting www.domain.com/default.aspx to www.domain.com.
A request to the first URL will trigger my rule to catch default.aspx. Then I output www.domain.com as the URL to redirect to.
Finally the module outputs www.domain.com/default.aspx as the destination URL. (according to the PDF manual of the module, this is expected behaviour)
So I am caught in an endless loop of the redirect triggering the rule to cause another redirect.
We need to somehow disable the adding of default.aspx by the UrlRewrite module…this may have something to do with the first problem.

Thanks in advance,
Shiraz

Comment By Tom Kraak on Monday, June 11, 2007 at 10:47 PM

Thanks for the kind words.

As for #1, both HREF Exchanger and UrlRewritingNet.UrlRewrite are HTTP modules, so they might get in the way of each other.

And #2 I'm still trying to figure out myself.

Let me do some testing and I'll report back here in a few days.

Comment By eoghano on Tuesday, July 31, 2007 at 9:00 AM

Thanks for sharing this Tom. This is something I have been seeking for quite a while.

Is there one other potential use of this? To set up a rule that will 301 any request for a specific DNN tab to a non-DNN page? If so how would the rule's syntax look? I read through the PDF manual that is available on the UrlRewritingNet.UrlRewrite website but it did not clarfy things for me. Do you have any insight/experience to this potential use of UrlRewritingNet.UrlRewrite?
Thanks
eoghano

Comment By Dan on Thursday, August 02, 2007 at 12:36 PM

Tom: thanks a million for this post.
Since April, I've read it probably 20 times, thought about setting it up a hundred times, and finally busted out a redirect.

I'm sorry I waited so long- it works PERFECTLY!

Comment By Tom Kraak on Thursday, August 02, 2007 at 4:30 PM

Thanks Dan, I'm glad you found it helpful.

Comment By Dax Davis on Thursday, August 16, 2007 at 12:53 AM

OK, in my quest to pull this off, this is where I'm at:

<add name="KickItWildStyle" virtualUrl="^http\://www.(.*).(.*)/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://$1.$2/$3.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />

With this if I surf to "http://www.rubicontechventures.com/" I am redirected to "http://rubicontechventures.co./Default.aspx". Almost perfect except for the ".co." intead of ".com". Any ideas?

Dax

Comment By Dax Davis on Wednesday, August 22, 2007 at 9:20 PM

Ah, come on. Someone has to know this answer. Any help would be appreciated.

Dax

Comment By Tom Kraak on Wednesday, August 22, 2007 at 9:25 PM

Dax, all you want to do is redirect from www to non-www like I do on this site?

Sorry, I just scrolled up now remember what you are after.

Comment By Dave Roe on Tuesday, August 28, 2007 at 7:14 AM

Hi, this is by far the best page on this that I've found - and I've looked at a lot.

My situation is this -

I have www.revahealthnetwork.com set up at one IP address. I have multiple domains redirecting to that, like revahealth.com, revadental.com which all work fine.
(In my web site identification though, I have multiple identities set for this site (both at the same IP address - one is www.revahealthnetwork.com, and the other has no host header value)

I want to permanantly redirect revahealthnetwork.com to www.revahealthnetwork.com

I have created a second site on the same box at a different IP address (that nothing points to right now) which also has two host header values - revahealthnetwork.com and another with a blank host header value.

That is redirecting to www.revahealthnetwork.com$S$Q
If I go direct to it's IP I get redirected okay to www.revahealthnetwork.com.

What I thought I could do next is to simply switch around the IP addresses, so all my domains that previously pointed to the IP for www.revahealthnetwork.com would now point to revahealthnetwork.com and get redirected to www.revahealthnetwork.com.
BUT
I get mutliple redirection and the requests abort.

Re-reading your original article, I see in your eamples, you do not show an IP address for either of your sites - either the www one and the non-www one.
Is that because the box you're on only has one IP, or are you blanking it out?
If the former - is that what I should be doing? Create both websites at the same IP?

One other solution is to go back to my DNS and have it point revahealthnetwork.com (and therefore all the other domains I have that forward to it) at the IP address of the revahealthnetwork.com and have it explicitly 301 to www.revahealthnetwork.com?

Or perhaps having these blank host header values is my problem?

Any help appreciated - I feel I've made this more complex than it needs to be....

Thanks,
Dave

Comment By xcentric on Wednesday, September 19, 2007 at 12:14 PM

Hello Tom,

Can this method be used to do 301 redirects from one page to another? Like services.htm > services.aspx? And if this is true how would I write the rule. So far I have this but its not working. I think I have something wrong but I dont know. Any ideas?

<add name="KickIt2" virtualUrl="http://www.domain.com/services.htm" destinationUrl="http://www.domain.com/services.aspx" redirect="Domain" redirectMode="Permanent" ignoreCase="true" />

Comment By Shemeka on Tuesday, November 06, 2007 at 7:50 PM

I need to move a portal from one host to another. As a result all of the urls will change. The old urls will no longer exist how do I implement 301 redirects in this case? Example:

www.helltruth.com/Home/HathHellNoFuryPart3/tabid/318/Default.aspx

will become

www.helltruth.com/Home/Hath-Hell-No-Fury-Pt-2.aspx

(new path will implement ventrians friendly urls module as well as take 1's hyphenation module)

Please advise as we don't want to have to start all over again with the search engines ...

Comment By Tom Kraak on Wednesday, November 07, 2007 at 2:16 AM

Merely moving hosting companies will not change your URLs. But switching to Ventrian's Friendly URLs provider obviously will change your URLs.

How many pages are you looking to 301-redirect?

Comment By Tom Kraak on Wednesday, November 07, 2007 at 3:18 AM

Shemeka - I just came across your post on dnn.com.

You can certainly move a DNN installation WITHOUT having to rebuild the portal from scratch and manually copying and pasting the content and reinstalling the needed modules.

Let me know if you still need details on that process.

Comment By Shemeka on Monday, November 12, 2007 at 4:23 PM

Really! I would definitely like to know the process for moving a portal. I did some searching for details on www.dotnetnuke.com but came away concluding that it couldn't be done. I've already manually moved two websites already and have more to go. I would love to know a better way.

Please advise.

Comment By Tom Kraak on Monday, November 12, 2007 at 10:46 PM

Have you seen the pinned post "FAQ: Moving a DNN installation" in the Install it! forum on dotnetnuke.com?

Comment By Shemeka on Tuesday, November 13, 2007 at 8:24 PM

No ... I'm going to check it out now! Thank you very much!

Comment By Chris Wylie on Friday, November 30, 2007 at 6:59 PM

Thanks Tom.

Your suggestions and download links helped me get this set up and working, both for www fold-over and a 301 redirect, within 30 minutes.

I can only guess at how long it took you to do all the research, experimentation and write-up.

I really appreciate it.

Chris

Comment By Tom Kraak on Friday, November 30, 2007 at 7:07 PM

Thanks Chris, I'm glad it was helpful.

Comment By SEO Company Canada on Wednesday, December 05, 2007 at 2:55 PM

Just what I needed for an ASP.Net project. Thanks! :)

Comment By wlater on Thursday, January 03, 2008 at 12:07 AM

since we've done that using the $Q$S method on IIS6, exactly as instructed, it first works fine, but then redirects all www.cybermight.com pages to www..cybermight.com. notice the 2 dots?
ever heard of that?

Comment By walter on Thursday, January 03, 2008 at 1:33 AM

found the problem, was coincidently that at the same time I implemented the 301 that a flash object update was made with an auto-redirect to www.. with the double dots

these flashers...

Comment By Rodney Joyce on Friday, January 25, 2008 at 1:11 AM

Hey Tom,
I love your blog - very good practical examples!

I have about 20 domains that all point at http://www.pokerdiy.com. I have set up 2 rules (one for the pokerdiy.com example and one for one of the other domains (homepokerhelp.com). Do I have to set up 2 Kicks for every single domain (with and without the www.*), or is there a way of pointing www.homepokerhelp.com AND homepokerhelp.com to pokerDIY in a single kick (ie. I need help with regex please. Is it something like: "virtualUrl="^http\://*.homepokerhelp.com/(.*).aspx"?

Here are my current rules:

<add name="KickIt" virtualUrl="^http\://pokerdiy.com/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://www.pokerdiy.com/$1.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />
<add name="KickIt2" virtualUrl="^http\://www.homepokerhelp.com/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://www.pokerdiy.com/$1.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />

Comment By Rodney Joyce on Saturday, February 16, 2008 at 10:17 PM

Hi Tom,

Can you give me any tips on the regex expression to handle the above question please?

Comment By Duc Hoang Le on Thursday, March 13, 2008 at 5:02 AM

Thanks Tom,

I'm using the IIS solution and it works well. However, does that mean I need 2 application pools for both of these sites? (www and non www)

Regards,
Duc

Comment By Tom Kraak on Thursday, March 13, 2008 at 5:33 AM

No Duc, the two sites can share one app pool without problem, since your "redirect site" is not a "real" IIS site to begin with ... as soon as the request comes in it will get "kicked over" to the real site where all the action happens.

Let me know if you have further questions.

Comment By ChoosingBroadband on Friday, June 20, 2008 at 4:11 PM

Thanks for this really useful article Tom. As I'm setting up multiple DNN portals I wanted a generic regex rule that would insert the missing "www." bits across all domains. (A similar requirement to Dax's but in reverse)

The <rewrites> entry below seems to do the trick. Hope it's useful for anyone wanting the same. Joe

...

<add name="www_it" virtualUrl="^http\://(?!www\.)(.*[\.com|\.net|\.co\.uk|\.info|\.org|\.ac])/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://www.$1/$2.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />

Comment By Paul on Wednesday, June 25, 2008 at 8:11 AM

I am sorry but I seemed to have lost the thread of this thread.

I have implemented this and its great. All works on multiple parent portals.

Now can I use this to rediect a .com to a .co.uk, or would it be the same if I just set up a redirection from the .com to the .co.uk through my hosting company. I am asking because I do not want any mistakes.

Comment By Tom Kraak on Wednesday, June 25, 2008 at 8:24 AM

Joe - thanks for posting your rewrite rule, much appreciated.


Paul - you can certainly use the tequniques and methods discussed above to redirect a .com to a .co.uk.

A redirection from the .com to the .co.uk set up by your hosting company will work just as well.

Whatever approach you end up going with, make sure your redirect produces a 301 HTTP status code. Use this tool

http://www.seomoz.org/toolbox/httpcode

to check on your status codes.

Comment By Rob on Wednesday, July 02, 2008 at 3:36 AM

I've finally tried this out and gained partial success.

I used ChoosingBroadband's version a couple of posts up so that it would work with multiple domains.

The domains successfully switched from non-www to www, but I find that seomoz.org reports code 200 rather than 301.

I also find that it doesn't work with subdomain names and tries to add the www ahead of them.

Anyone have any ideas for fixing these bits?

Comment By Mark on Friday, July 04, 2008 at 10:58 AM

Anyway of getting the website IIS lists in alphabetic order?

Very tricky when you get more than a page full.

Comment By Choosing Broadband on Friday, July 04, 2008 at 12:02 PM


Rob,

I've amended my regex rule to cater for subdomains. I've also inserted an extra rewrite rule up on top. This allows one extra level for the uk TLD, as this is has a mandatory 2nd level domain ie: .co.uk and .org.uk. (More rewrite rules may be needed if you want to cater for other legit 2nd level domains.) Here's the config block...

<urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" defaultPage="default.aspx" defaultProvider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
<rewrites>
<add name="www_uk" virtualUrl="^http\://(?![^\.]+\.[^\.]+\.[^\.\/]+\.)(.*[\.uk])/(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="http://www.$1/$2.aspx" redirect="Domain" redirectMode="Permanent" ignoreCase="true" />
<add name="www_rest" virtualUrl="^http\://(?![^\.]+\.[^\.\/]+\.)(.*[\.ac|\.biz|\.cn|\.com|\.de|\.edu|\.info|\.name|\.net|\.org|\.pro])/(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="http://www.$1/$2.aspx" redirect="Domain" redirectMode="Permanent" ignoreCase="true" />
</rewrites>
</urlrewritingnet>

I've hard coded a list of tld's in the options segment >> [\.ac|\.biz|\.cn|\.com|\.de|\.edu|\.info|\.name|\.net|\.org|\.pro]
<< clearly you may need to add/subract tld's to your own requirements.

I tried seamoz.org to check the httpcode for one of my domains but the checker seems broke at the moment. (It didn't report anything!) I have used httptracer from lazydogutilities.com to check the codes returned and this reports a 301 code.

Joe

Comment By Tom Kraak on Friday, July 04, 2008 at 12:40 PM

Mark - select "Web Sites" in the left pane of IIS and then sort by clicking on the column headings in the right pane.

Joe - thanks for continuing to add value to this post ... much appreciated!

Comment By Atzmon Seo on Saturday, July 05, 2008 at 2:20 PM

Great tip fro doing 301 redirect.
I try it and it work.

Thanks
Atzmon
http://www.pirsumyashir.co.il

Comment By Alex on Thursday, August 21, 2008 at 11:58 PM

Great post. This was really helpful.

Comment By busse on Tuesday, August 26, 2008 at 5:50 PM

Just wanted to say "thanks" for this -- it really helped me out today!

Add a comment
Add to Technorati Favorites

Email Updates

Enter your email address below and find our blog updates in your inbox.