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

First time here? You may want to check out the blog archive, subscribe to the RSS feed, sign up for free email updates, or follow me on Twitter. Thanks for visiting!

Search Engine Friendly 301 Redirects Without Touching IIS 

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.




Comments

vasilis vasilis says:

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

Great tips! Well done!

Tom Kraak Tom Kraak says:

Thanks. What are "ices" though?

Exiton Exiton says:

Doesn't work.

Says:

DotNetNuke Error: - Version 04.05.01

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

Tom Kraak Tom Kraak says:

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

Exiton Exiton says:

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





rewriteOnlyVirtualUrls="true"
contextItemsPrefix="QueryString"
defaultPage = "default.aspx"
defaultProvider="RegEx"
xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >

rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://www.dotnetnukeru.com/$1.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />





Tom Kraak Tom Kraak says:

And the .dll is in the bin folder?

Exiton Exiton says:

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

Tom Kraak Tom Kraak says:

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

Exiton Exiton says:

Sent.

Tom Kraak Tom Kraak says:

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

Exiton Exiton says:

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/ (or better yet .sitename.dz) to www.sitename.dz/Default.aspx?tabid=?

Tom Kraak Tom Kraak says:

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.

green green says:

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

xcentric xcentric says:

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.

xcentric xcentric says:

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

Tom Kraak Tom Kraak says:

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.

xcentric xcentric says:

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?

Tom Kraak Tom Kraak says:

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.

xcentric xcentric says:

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.

Tom Kraak Tom Kraak says:

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

xcentric xcentric says:

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?

Tom Kraak Tom Kraak says:

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

xcentric xcentric says:

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

Tom Kraak Tom Kraak says:

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

Dax Davis Dax Davis says:

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

Tom Kraak Tom Kraak says:

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.

Exiton Exiton says:

I have multiple portals installed and everything is working fine.

Dax Davis Dax Davis says:

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?

Tom Kraak Tom Kraak says:

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

Brian Brian says:

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

Tom Kraak Tom Kraak says:

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

Dax Davis Dax Davis says:

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:

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

Tom Kraak Tom Kraak says:

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

Dax Davis Dax Davis says:

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

Tom Kraak Tom Kraak says:

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

Shiraz Asif Shiraz Asif says:

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

Tom Kraak Tom Kraak says:

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.

eoghano eoghano says:

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

Dan Dan says:

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!

Tom Kraak Tom Kraak says:

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

Dax Davis Dax Davis says:

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

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

Dax Davis Dax Davis says:

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

Dax

Tom Kraak Tom Kraak says:

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.

Dave Roe Dave Roe says:

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

xcentric xcentric says:

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?


Shemeka Shemeka says:

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 ...

Tom Kraak Tom Kraak says:

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?

Tom Kraak Tom Kraak says:

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.

Shemeka Shemeka says:

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.

Tom Kraak Tom Kraak says:

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

Shemeka Shemeka says:

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

Chris Wylie Chris Wylie says:

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

Tom Kraak Tom Kraak says:

Thanks Chris, I'm glad it was helpful.

SEO Company Canada SEO Company Canada says:

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

wlater wlater says:

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?

walter walter says:

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...

Rodney Joyce Rodney Joyce says:

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:

rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://www.pokerdiy.com/$1.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://www.pokerdiy.com/$1.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />

Rodney Joyce Rodney Joyce says:

Hi Tom,

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

Duc Hoang Le Duc Hoang Le says:

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

Tom Kraak Tom Kraak says:

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.

ChoosingBroadband ChoosingBroadband says:

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 entry below seems to do the trick. Hope it's useful for anyone wanting the same. Joe

...

rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="http://www.$1/$2.aspx"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />

Paul Paul says:

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.

Tom Kraak Tom Kraak says:

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.

Rob Rob says:

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?

Mark Mark says:

Anyway of getting the website IIS lists in alphabetic order?

Very tricky when you get more than a page full.

Choosing Broadband Choosing Broadband says:


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...








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

Tom Kraak Tom Kraak says:

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!

Atzmon Seo Atzmon Seo says:

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

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

Alex Alex says:

Great post. This was really helpful.

busse busse says:

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

Laurence Laurence says:

Here's a question about UrlRewritingNet:

I want to set up a 301 redirect from:

http://www.company.co.uk/MENS/CATEGORY/SweatsLeisure/tabid/3000/List/0/CategoryID/90/Level/a/Default.aspx?SortField=ISBN,ProductName

to:

http://www.company.co.uk/MENS/CATEGORY/SweatsLeisure/tabid/3000/Default.aspx

I succeeded in getting the redirect to go to:

http://www.company.co.uk/MENS/CATEGORY/SweatsLeisure/tabid/3000/Default.aspx?SortField=ISBN,ProductName

The only thing missing now is to stop the querystring parameters from
being added to destination URL. My rule is:


< add name="Redirect long-form to short-form product page URLs"
virtualUrl="(.*)/TabId/(\d+)/List/\d+/CategoryID/\d+/Level/a/
Default.aspx"
destinationUrl="$1/TabId/$2/Default.aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" / >


I cannot find a way to the stop the querystring parameters - how do I
do it?

Laurence Laurence says:

Another question!

Has anyone experienced their site using huge amounts of memory after installing UrlRewritingNet? I installed it in a DotNetNuke site (using tips in this article - thanks!). Before installing, the app pool for the site consumed about 200mb of memory. After installing, within a few hours, the app pool was consuming over 1Gb of memory.

Below is my config. The first 2 rules are for redirecting domains to the primary domain www.company.co.uk. The 3rd and 4th rules are for redirecting and rewriting URLs.

< urlrewritingnet
rewriteOnlyVirtualUrls="true"
contextItemsPrefix="QueryString"
defaultPage="Default.aspx"
defaultProvider="RegEx">
< rewrites>
< add name="Redirect domain 1"
virtualUrl=".*company.com/(.*)"
destinationUrl="http://www.company.co.uk/$1"
rewriteUrlParameter="ExcludeFromClientQueryString"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />
< add name="Redirect domain 2"
virtualUrl="http://company.co.uk/(.*)"
destinationUrl="http://www.company.co.uk/$1"
rewriteUrlParameter="ExcludeFromClientQueryString"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />
< add name="Redirect long-form to short-form product page URLs"
virtualUrl="(.*)/TabId/(\d+)/List/\d+/CategoryID/\d+/Level/a/Default.aspx"
destinationUrl="$1/TabId/$2/Default.aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />
< add name="Rewrite short-form product page URLs to add parameters CATALook needs (to avoid CATALook forcing 302 redirect to add parameters)"
virtualUrl=".*/(CATEGORY|BRAND)/(.*)/tabid/(\d+)/Default.aspx(.*)"
destinationUrl="~/Default.aspx?TabId=$3&List=0&CategoryID=$3&Level=a&SortField=ISBN,ProductName"
rewriteUrlParameter="ExcludeFromClientQueryString"
redirect="None"
rewrite="Application"
ignoreCase="true" />
< /rewrites>
< /urlrewritingnet>

Russ Russ says:

Thanks for the great how-to, Jaan.

I went and created a new site in IIS, using 'all unassigned' for the IP because when I tried using the same IP as our www.keene.edu site, it wouldn't let me start the service. It threw an error saying there was a duplicate address on the network.

After I created the non-www site, I went into Properties and selected 'A redirection to a URL' and set it to http://www.keene.edu and also selected 'The exact URL entered above' and 'A permanent redirection for this resource.'

I also created a root directory for this non-www 'site' and put a default.cfm page with the 301 redirect using Coldfusion.

Still, when you go to http://keene.edu, you get that "Error. No Cache." page.

Any suggestions?

Thanks a lot.

Russ

Tom Kraak Tom Kraak says:

Thanks Russ - looks like it's working now.

Franklin Franklin says:

Great tool!!! Congratulations and thank you very much. I have a quick question hope somebody can help. Im using this tool to redirect from www.mysite.com/whatever.aspx to mysite.com/whatever.aspx and it works great. My little problem is that when you type mysite.com it display my home page correctly but when you type www.mysite.com it redirect correctly but the URL shows mysite.com/Home.aspx I dont want that "Home.aspx" to be displayed. Any help would be greatly appreciated. Thanks in advance.

Jon Abbott Jon Abbott says:

Great tool, thanks!

chris w. chris w. says:

Hey just wanted to thank you for the article, it was most helpful. Could I bug someone with a question?

I'm trying to shorten the default ventrian articles url like you've done. Except so far I've only had luck creating shorter links that are accepted, but not populated through the modules without a loop. Here's what I got.


rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="$1/Articles/tabid/$2/articleType/ArticleView/articleId/$3"
redirect="Domain"
redirectMode="Permanent"
ignoreCase="true" />

The one that's commented out results in a loop when active. As it is I can provide the shorter links but they obviously direct back to the longer one. Can anyone share some insight into what I'm trying to accomplish?

Cheers and thanks again!

Frank Frank says:

After reading all of these excellent posts, I am still not clear on how to do a 301 Redirect when you are redirecting an existing DNN site on a self-hosted server to an entirely new version of the website on a new server at a hosting company.

I did not "move" the site, as would be the preferred method, as I was unable to get past an error in upgrading from 4.5.5 to 4.9.2 and I ending up with a fresh install of 4.9.2 on Mosso and just recreated each page from the old portal.

Before I change DNS to point to the new instance (Mosso), I want to create 301's for each old page to each new page. If I create the 301's on the old server and change DNS to point to the new server, how will search engines be able to find the 301?

Do I need to create the 301's on the new server? If so, would your module do what I need? Thanks for any light you can shed on this.

Frank

Tom Kraak Tom Kraak says:

@ Frank - none of this has anything to do with were the old/new site is physically hosted. iFinity Url Master installed on the new (Mosso) DNN install will take care of the 301's for you.

Chris Chris says:

I am running IIS 6 with .NET 3.5 installed. I'm using one IP per server with multiple virtual sites. I wish this were as easy as it sounds but I'm stuck at "isntalling .dll in /bin directory". These are basic sites setup as applications but there are no bin directories. Suggestions please?

Many thanks,
Chris

Tom Kraak Tom Kraak says:

@ Chris - simply create a bin directory. Have you tried that?

Chris Chris says:

Tom,

Thank you for your response!

No I have not. I suppose it doesn't matter where I create it as long as I point to it in the web.config file, correct?

Tom Kraak Tom Kraak says:

@ Chris - create the bin directory in the root of our website.

Chris Chris says:

I have 250 sites on this particular server. Are you saying I would need to do this for each site individually?

Tom Kraak Tom Kraak says:

@ Chris - in that case you should not be using UrlRewritingNet, but instead install ISAPI_Rewrite 3 on the server.

Chris Chris says:

Thanks Tom! With any luck I can get away with using the lite version. I'll go check it out.

Thanks again,
Chris

Raghu Pandey Raghu Pandey says:

Thanks a lot Tom... this article was really helpful. You are right most articles on net talk about linux/apache. Yours is an important resource for iis users!

Shiju Alex Shiju Alex says:

Hi Tom,

Thank you for the article and introducing this useful dll

I think I will have to play around a bit, to make something out of it.

Nayak Nayak says:

Hi there,

Thanks a zillion for this wonderful article. Just to let you know, I have implemented the same and my prod folder is now looking neat and clean.

I do have a question for you also, can I read the rewrite parameters (such as virtualUrl, destinationUrl etc) from an XML file rather than hard coding them in to a web.config file or an external config file. Is there any way to archive this?

Thanks again for your help.

Regards,
Subhasis

Milan Andreev Milan Andreev says:

Hello i have one simple question, I need just 301 redirect from:
http://alexandriacomputers.com
to:
http://www.alexandriacomputers.com
i have no permission to iis beacuse i use shared host. can i do it with some code in web.config? if i can, can u write me a simple redirect code fror nonWWW to WWW. Thank you!
i'am using UrlRewriter.NET

Tom Kraak Tom Kraak says:

@ Milan - see this thread for one possible solution.

joseph joseph says:

Hi great post. I have searched and searched and can't find this solution.
www.example.com/products/productname.htm?q=something
This is a static site I have ISAPI_Rewrite installled on the server and do 301's etc.
I need the above url to be a 404 and not throw a 200 in the header. Any help would be much appreciated.

TomKraak TomKraak says:

@ Joseph - your best bet is the ISAPI_Rewrite forum.

armando armando says:

Hi, I've looked at your blog and followed your instructions very carefully. However, i cannot get the redirection from non www to www. I added the 3 settings in config file and added dll fine to bin folder with no success.

I have dnn masters url rewriter so i'm not sure i that's causing it not to work, however, i disabled it and still didn't work.

Any help with this would be greatly appreciated.

Thanks.

Tom Kraak Tom Kraak says:

@ Armando - the above should still work, but it's a bit dated, especially when it comes to DNN.

The easiest way to redirect non-www to www on shared hosting is via the iFinity Url Master module, which I consider far superior to the DNN Master module.

Nayak Nayak says:

rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString"
defaultPage = "default.aspx"
defaultProvider="RegEx"
xmlns="http://www.urlrewriting.net/schemas/config/2006/07">

rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/residential/paying-your-bill.aspx"
redirect="Application"
redirectMode="Permanent"
ignoreCase="true" />




My rule looks like the above but instead of giving a 301 redirect it give me a 302 redirect, any reasons ? How can i convert it to 301 redirect

Colin Colin says:

HI,

I have a question about 301 redierects in terms of multiple domain names;

I have 3 domains that I wish t redirect to a single dnn site.

If you could answer that one for me it would be great.

Regards
Colin

TomKraak TomKraak says:

@ Colin - there are a number of ways to do this. What kind of hosting environment are you on? Shared or dedicated? What control do you have over IIS?

Comments are closed

Subscribe to our Feeds Follow on Twitter