From 79f24733884eedd6f90a466b66813524344db73e Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 14 Sep 2024 17:05:29 +0100 Subject: [PATCH] Remove trailing slashes from URLs --- source/.htaccess | 15 +++++++++++++++ source/_includes/zets/related.html.twig | 2 +- source/index.html.twig | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 source/.htaccess diff --git a/source/.htaccess b/source/.htaccess new file mode 100644 index 0000000..3715179 --- /dev/null +++ b/source/.htaccess @@ -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] diff --git a/source/_includes/zets/related.html.twig b/source/_includes/zets/related.html.twig index 3703375..54e14ed 100644 --- a/source/_includes/zets/related.html.twig +++ b/source/_includes/zets/related.html.twig @@ -5,7 +5,7 @@ diff --git a/source/index.html.twig b/source/index.html.twig index 6cc6d89..0e104bb 100644 --- a/source/index.html.twig +++ b/source/index.html.twig @@ -7,7 +7,7 @@ use: [zets]