Textline (PH): +63.915.355.5580 | +63.925.882.2328
Telephone (PH): +63.32.347.2338
  US: +1.818.478.8015

Using .htaccess to redirect non-www to www and vice-versa

SEO Tips - Redirect non-www to www using htaccess


Use the code below to redirect non-www to www:

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

This will redirect http://domain.com to http://www.domain.com.

What are the benefits of redirecting a website:

  1. Avoid duplicate content in  Google and other Search Engines.
  2. Avoid split page rank for inblound links.
  3. A more consistent URL.


Redirecting from www to non-www using htacess

 Use the code below if you want to do the opposite:

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

 Be sure to replace domain.com with your own domain.

 That's it.

Cebu Web Solutions offers Digital Marketing Services, SEO Services, Facebook Marketing, Web Design and Development Services
1078 Basak
Cebu City
1078 Cebu South Road Basak Cebu City 98052
(032) 347-2328 Cebu Web Solutions Digital Marketing Company in Cebu City, Philippines offers Digital Marketing services in Philippines ,USA,Australia.