I have never really thought about it before, but I hardly ever type ‘WWW’ into an address bar. Out of habit I skip this part of any URL. It has never caused me any problems till this week, for one of my own websites.
As I’ve said in an earlier post, I have added OpenID support to one of my websites. I used the DotNetOpenId library. This library made the development very easy and was up and running in no time on my development machine. But recently I have published the website to a live server and things haven’t been going that smoothly.
Redirecting turned out to be easier than I thought (I didn’t need to contact hosting provider). I just added a ‘.htaccess‘ file to the root of my directory with the following lines
RewriteEngine OnRewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
This tip I got from no-www.org.


#1 by Andrew on November 9, 2008 - 01:55
Hi Trevor,
There shouldn’t be a need to store what the OpenID the user typed in in your Session state. Instead, you should be looking at the IAuthenticationResponse’s ClaimedIdentifier and FriendlyIdentifierForDisplay properties and using those when the user logs in.
In general, you should never store the text value the user typed in because doing so introduces several security problems that could allow attackers to spoof identity of your users.
I would hope that would solve your www vs. no-www problem as well.
#2 by Trevor Power on November 9, 2008 - 17:35
Hi Andrew,
Thanks for the tip. I will make your suggested changes. But I will keep the redirect to avoid problems with the ‘realm’.