# Disable directory listings (mod_autoindex) Options -Indexes # Prevent mod_dir appending trailing slash to directories DirectorySlash Off RewriteEngine On # Remove the trailing slash, should it appear on any 3rd party requests RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{REQUEST_URI} ^/(.+)/$ RewriteRule /$ /%1 [R=301,L] # Rewrite the URL to append a trailing slash to directories (internally) RewriteCond %{REQUEST_FILENAME} -d RewriteRule (.*[^/])$ $1/ [L] # 301 REDIRECT HTTP TO HTTPS AND WWW TO NON-WWW RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(www\.)?(.+) RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]