Force trailing slash to avoid duplicate content using htaccess

Use the code below to force a trailing slash on your web site URLs.

When would you use this?
Search engines, most notably Google will view the two URLs below as different pages, and by doing so, will possibly get flagged for duplicate content.

By forcing the trailing slash on your URL's you prevent duplicate URLs and also keeps your anaytics tidier as there will only be one url in your reports.

RewriteEngine on
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Solving the ERR_BLOCKED_BY_XSS_AUDITOR in Chrome

You are reading this article because you have saved something in wordpress and received an error...

Additional security/performance settings for htaccess

Below is some additional rules for your htaccess file which provides some performance and...

Forcing SSL and WWW in htaccess

Use the following code in the htaccess file for making sure that all pages served up are www and...

301 redirect all traffic from domain A to the root of domain B

If you need to 301 redirect all the traffic from to the index page of

Fix WordPress 404 Errors on Password Protected Directories

You are reading this article becasue you have applied password protection on the wp-admin...