WWW Redirection with .htaccess

iniciar sesión

¿Quieres conseguir más ventas para tu negocio?

Aprende a crear y automatizar un proceso de generación de leads para tener un flujo constante de clientes para tu empresa, sin malgastar dinero en publicidad de pago.

WWW Redirection with .htaccess

11-8-2013     Basic SEO

WHAT ADVANTAGES DOES IT HAVE?

Performing a correct domain redirection from the domain without WWW to the domain with WWW or vice versa has certain advantages for SEO:

– Prevents duplicate content problems in Google

– Prevents possible PageRank fragmentation between subdomains

– Prevents fragmentation of inbound links popularity

– It gives your website general consistency

If your domain has already been indexed by Google without the WWW you may lower your PageRank temporarily when applying changes.

In any case, as you indicate in the code that it is a 301 permanent redirect, Google will soon pass all your PageRank and inbound links to the new domain.

 

THE .HTACCESS FILE

A permanent redirection can be created with the .htaccess file

It is a hidden file located in the root folder of your website, so you’ll have to activate the «view hidden files» option in your FTP client preferences.

.htaccess File

The .htaccess file in the root folder of a WordPress website

 

THE CODE

If you use the following code in your .htaccess file you will create a permanent 301 redirect from the domain without WWW to the domain with WWW:

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

On the other hand, if you use the following code the redirection will be from the domain with WWW to the domain without WWW (replace «yourdomain» and «.com» for your domain name and the TLD of your Website):

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






Deja tu comentario:


¡Deja tu comentario!

(Anti-Spam)