Lego2012
7/17/2017 - 9:15 AM

Structural Avoidance of Duplicate Content

Structural Avoidance of Duplicate Content

First, let’s make sure that, when using HTTPS, the respective protocol is always used, and that there are no more deliveries via HTTP. Using Mod_rewrite and htacces, this is done like this:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://www.drweb.de/$1 [R=301,L]

In order to assure that the www is always added to the URL, avoiding duplicates due to a missing protocol specification, write:

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

Now, let’s take care of the ending slash at the end of URLs. This is a problem that a lot of you won’t have, but it is easy to prevent. So why not do it? This htaccess causes every URL to receive the ending slash:

RewriteEngine On
%{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ https://www.drweb.de/$1/ [R=301,L]

You remain free to go the reversed way, in order to always avoid the slash. The same applies to forcing the www. It’s just important to keep the consistency throughout your entire website.