1

I have the following content in my .htaccess file place in the root directory:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

The thing is, the '.html' does get removed from the URL, but the trailing slash is nowhere to be seen. Why? Many thanks

Mihir Chaturvedi
  • 266
  • 1
  • 5
  • 12

1 Answers1

0

You need to place your 301 RedirectRules before internal rewriteRules and make the trailing slash optional in your Rule's pattern.

Try :

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ $1/ [L,R=301]    
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/.]+)/?$ $1.html [NC,L]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115