Back To Resources, Guides and Information

.htaccess Trick: Redirect www Visitors To Your Non-www Site

This was posted on 04/03/2011 and was filed in Tips And Tricks, .htaccess, How-Tos | (No Comments Yet)

I use this ALL the time, so It's nice for me to have a quick place to reference it and I figure there are others out there looking for something like this. If you want to completely remove the www. from your domain name when visitors visit your website, place the following code snippet into your .htaccess file.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

This is the same code that my site and my clients' sites use to remove the www from their domain name when a visitor searches. This will simply and cleanly redirect any link to your site to the non-www version. For example, http://www.maxmorgandesign.com/contact/ simply becomes http://maxmorgandesign.com/contact/. Easy,  yeah?

Have I Helped You? Share Some Love!

Comments

» No Comments have been made on this. How about you start us off?

Comment On This

© Max Morgan Design 2009 - 2012 | Page Generated In 0.20784 Seconds Using 42 MYSQL Queries