0

Apologies but I'm fairly new to URL Rewrites. I've managed to get the rewrite working in the conventional sense but cannot force it to have a trailing slash.

Here is the code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ /$1.html [L,QSA]

1 Answers1

0

You can try:

RewriteEngine On
RewriteBase /

# add a trailing slash for non-files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)/?$ $1.html [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643