How to redirect from www.domain.com to domain.com

Rewrite rule to redirect http://www.domain.com to http://domain.com on Apache server by editing .htaccess file.

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

OR

Rewrite rule to redirect http://domain.com to http://www.domain.com

RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

Obviously you need to REPLACE domain.com and www.domain.com with your actual domain name.

bookmark me:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • BlinkList
  • Furl
  • Ma.gnolia
  • StumbleUpon
  • Technorati
  • LinkedIn
  • MySpace
  • Reddit
  • TwitThis

0 comments

There are no comments yet...

Kick things off by filling out the form below.

Leave a Comment