Using htaccess To Force Trailing Slash

You can use htaccess to change the URL structure of your website. There are lots of things you can do with htaccess one of the most common things would be to make sure all the pages are prefixed with the www subdomain or to make sure all the pages are not prefixed with the www subdomain.

Many people often say that they want their URL structure to always have a trailing slash at the end of the URLs. This can be done by using htaccess. If the URLs don't have a trailing slash the htaccess will redirect the browser to the URL with a trailing slash.

Copy the following in your htaccess file to add a trailing slash to your website.

<IfModule mod_rewrite.c>
 RewriteCond %{REQUEST_URI} /+[^\.]+$
 RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]


Reliable uptime monitoring and instant alerts for any website downtime.

  • Uptime Monitoring
  • Performance Monitoring
  • SSL Certificate Alerts
  • Domain Monitoring
  • DNS Checker
  • XML Sitemap Monitoring