Showing posts with label Mod rewrite. Show all posts
Showing posts with label Mod rewrite. Show all posts

Wednesday, February 6, 2013

Domains with www. and without www


The search engines like Google , Yahoo , Bing , and others, do not like that there is content duplicated on the web, for example, is very common that a given domain has two inputs, with www and without www at the beginning ( www . dominio.com and dominio.com ). This can present problems for our site because if you Google our Pagerank , rather thanincrease , may be affected . To avoid duplication of pages registered, we will have to make a decision.
There are several ways to force the system to using a 301 redirect , our domination takes one of two forms . For those working on a server Apache and therefore have the ability to create and edit a file . htaccess in the root of your server, you can choose to add one of the following codes:
If we want all accesses are redirected to a domain with www, we add:

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

If our intention is to remove the prefix www to our access, this is the code:


RewriteEngine On
RewriteCond% {HTTP_HOST} ^ www. (.) $
RewriteRule ^ (.) $ Http://% 1 / $ 1 [R = 301, L]
The choice is yours. You must choose one of the two.