Redirect http://www.your-domain.com to http://your-domain.com

By adding a few lines of code to the .htaccess file, you can redirect users.

First, why would you want to redirect a user from http://www.your-domain.com to http://your-domain.com, or vice versa?  Here are two simple reasons:

  1. SSL is only for either www.your-domain.com or yourdomain.com - in the case that you purchase SSL for an online store or secure data transfer area of your website, you can be consistent.
  2. SEO efforts work better when you are consistent.  By choosing www or no-www, you can focus your SEO strategy when linking to your site.

Here's the code:

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\.your-domain\.com$ [NC]
RewriteRule ^(.*)$ http://your-domain.com/$1 [R=301,L]

The other way 'round

If you want to do the opposite, then use this:

# redirect if www.example.com (case-insensitive) to example.com 
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] 
RewriteRule (.*) http://example.com/$1 [R=301,L] 

Category:

Author: rosschapman

Created on: July 10th, 2008

Comments

fivln , [url=http://www.xethqqlkqj.com]m4838[/url], http://www.azkrcwjolp.com sxwb7">fbpve wycqp

3 days ago

CBLDS, fivln , [url=http://www.xethqqlkqj.com]m4838[/url], http://www.azkrcwjolp.com sxwb7

fivln , [url=http://www.xethqqlkqj.com]m4838[/url], http://www.azkrcwjolp.com sxwb7">fbpve wycqp

3 days ago

CBLDS, fivln , [url=http://www.xethqqlkqj.com]m4838[/url], http://www.azkrcwjolp.com sxwb7

jocbz , thanks!">jocbz

1 day ago

pZwYt, Hi, you have a great site! jocbz , thanks!

Lvfmtyxa

about 9 hours ago

Nice work, thanks , sexy teen angels , pay sex teen , body perfect sex teen ,

leave a comment

Back to article list