Avoiding Duplicate Content on Apache Web Server Using .htaccess

Views: 166
Reading Time: <1 minute

In this post I will demonstrate how to avoid one of the major SEO problems, which is duplicate content, that is, two or more URLs on your website have the same content. For SEO, this is terrible, because clicks and views are counted separately according to the way your URL is written. Although it seems just a detail, duplicate content is one of the biggest bad guys with bad rankings 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 the URL's, 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