Fixing duplicate content using redirection 301

Tuesday, 12 June 2012 12:50

Apache redirect 301 fixing duplicate content using redirection

Fixing duplicate content using "canonical redirect"

There is nothing more embarrassing in the world of SEO than duplicate content. If you are caught with duplicate content, it�s a one-way ticket to Internet detention in the eyes of Google. Sure, the first few times you walk away with a sore wrist and your content taken down. But if you continue to consciously duplicate your content, your website could be wiped away from Web existence. Now that�s heavy.

It is really critical to eliminate duplicate content as soon as possible. Let's imagine you have www.java-tutorial.ch and java-tutorial.ch returning the same content. google will consider that as duplicate content and if you have the�good idea to link your website using both link�you a splitting the potential benefit of valuable link popularity.

Using 301 redirect

Our recommendation is to use a server side 301 redirect . This is the best way to ensure that users and search engines are directed to the correct page. The 301 status code means that a page has permanently moved to a new location.

How To Enable The 301 Redirect

Enable the redirection is quite simple and can be done in three steps :

  1. Enabling�the rewriting module in Apache
  2. Creating a .htaccess file to implement the rule
  3. Defining the rewriting rule

Enabling the rewriting module

The rewriting module in Apache is called mod_rewrite. In order to use mod_rewrite you can type the following command in the terminal:

a2enmod rewrite

The Apache server�s mod_rewrite module gives you the ability to transparently redirect one URL to another, without the user�s knowledge. This opens up all sorts of possibilities, from simply redirecting old URLs to new addresses, to cleaning up the �dirty� URLs coming from a poor publishing system � giving you URLs that are friendlier to both readers and search engines.

To check if the module has been loaded your can execute the following command to list the modules

apache2ctl -M

Creating a .htaccess file to implement the rule

Put a .htaccess file in your root so that rewriting is enabled throughout your site. You only need to write this snippet once per .htaccess file.

#
# mod_rewrite in use
#
RewriteEngine On 

Defining the rewriting rule

Once you've done that simply add the following code to the .htaccess file.This code will tell your site to redirect any visitors who visit your site without inputting the WWW to your WWW domain.

The technical term for this type of redirect is " Canonical Redirect ".

# redirect non www to www 
RewriteCond %{HTTP_HOST} ^java-tutorial.ch RewriteRule (.*) 
https://www.java-tutorial.ch/$1 [R=301,L] 

You can now restart your apache server then enter your web site url without the www in the following website form .

You should receive the following response :

Response

Checked link: https://java-tutorial.ch
Type of redirect: 301 Moved Permanently
Redirected to: https://www.java-tutorial.ch/


Tags: content , apache , link , duplicate , rewriting , module , website