+63-969-086-2100
: sales[at]cebuwebsolutions.com

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 Cebu South Road, Basak San Nicolas
Cebu City
Cebu
6000
Philippines