Avoiding Duplicate Content on Apache Web Server Using .htaccess

Views: 161
Reading Time: <1 minute

In this post I will demonstrate how to avoid one of the major SEO issues, which is duplicate content, ie two or more URLs from your website contain the same content. For SEO, this is awful, because clicks and views are counted separately according to how your URL was typed. Although it seems like just a detail, duplicate content is one of the biggest bad-rank villains in search engines and content aggregators.

As a prerequisite for implementing .htaccess code, your Apache server must already have the mod_rewrite module enabled.

Through the codes I will show you below, we can get around this quickly and practically. It comes down to 3 types of redirects that will be performed by Apache:

  • Enter www in URL if you don't have: Causes http://domain.com and http://www.dominio.com to represent the same URL. When entering the address without WWW Apache will redirect to the URL with WWW automatically.
  • Remove / at end of link: Causes the “/” character to be removed at the end of URLs, causing http://www.dominio.com.br/ to be directed to http://www.dominio.com.br
  • Remove index.php: Performs the link redirection http://www.dominio.com.br/index.php to http://www.dominio.com.br, avoiding content redundancy on the main page of your site