Remove trailing slashes from URLs

This commit is contained in:
Oliver Davies 2024-09-14 17:05:29 +01:00
parent 6d4667887d
commit 79f2473388
3 changed files with 17 additions and 2 deletions

15
source/.htaccess Normal file
View file

@ -0,0 +1,15 @@
Options +FollowSymLinks -MultiViews
RewriteEngine on
# Remove trailing slashes from directories.
DirectorySlash Off
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_FILENAME}/index.html -f
RewriteRule (.*) $1/index.html [L]
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Remove index.html from URLs.
RewriteCond %{THE_REQUEST} \s/+(.*/)?index\.html[\s?] [NC]
RewriteRule ^(.*)index\.html$ /$1 [L,R=301]