Redirect your WWW requests to
August 10, 2007
Hello
There is a movement out there to remove the old WWW from URL’s, or at least make web site accessible from both the WWW and no-WWW URL.In other words, you should be able to reach my website by using both http://www.port16.com and http://port16.com.
To be perfectly honest, I don’t really see what all the fuss is about. I don’t think that people will ever stop typing the WWW, it is just a little too ingrained in us.
Personally, I want both URLs to work, because when I type the domain somewhere, like in a web form, I save 4 keystrokes by not using the “www.”. On the flip side, when I type in the URL in the address bar of my web browser, I type in port16, then use the shortcut CTRL+ENTER to fill in the “www.” before it, and the “.com” after it. This way I save 6 keystrokes.
I know it may seem a little lame to try and save those keystrokes, but when you perform a simple, like typing in a URL, over and over, those keystrokes add up. Try the CTRL+Enter shortcut, I bet you will love it. I could post all day about saving keystrokes and shortcut keys, and I’m sure I will, but I digress.
My website was accessible using both methods, but if you used http://www.port16.com, you remained at that URL until you followed a link, so I was worried that some search engines, or other applications, would see 2 different web sites, one with the WWW and one without.
One word of caution, you should really think about how your users are accessing your site before making this change. One example that immediately comes to mind is with RSS feeds. If all your feeds point to www.yoursite.com, then you may not want to make this change, or you may want to redirect from http://yoursite.com to http://www.yoursite.com. Just a thought.
Performing this redirection is really easy to do in Apache, which is what WordPress uses.
1. In the root of your site, there should be a file named “.htaccess”. Open the file for editing. Note: If you download the file, Windows may name it “htaccess” instead of “.htaccess”. This doesn’t damage the file, but it won’t work when you upload it, unless you rename it. It is just easier to edit it live.
2. Move down to / create a a blank line at the end of the file.
3. Look for a line that reads “RewriteEngine on”. The line may not be in the file, but we need to find out if it is.
4. Enter the code below into the file. If you found the line “RewriteEngine on”, then only enter the last 2 lines. “RewriteEngine on” only has to appear 1 time in the file.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
5. Edit the lines to match your domain. Be careful not to delete or overwrite the other characters. For Port 16 I changed the file to:
RewriteEngine On RewriteCond %{HTTP_HOST} ^www.port16.com$ [NC] RewriteRule ^(.*)$ http://port.com/$1 [R=301,L]
Posted in
content rss

Recent Comments