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]

View file

@ -5,7 +5,7 @@
<ul>
{% for zet in zets if related|filter((title) => title == zet.title) %}
<li>
<a href="{{ zet.url }}">{{ zet.title }}</a>
<a href="{{ zet.url|trim('/', 'right') }}">{{ zet.title }}</a>
</li>
{% endfor %}
</ul>

View file

@ -7,7 +7,7 @@ use: [zets]
<ul>
{% for zet in data.zets %}
<li>
<a href="{{ zet.url }}">
<a href="{{ zet.url|trim('/', 'right') }}">
{{- zet.date|date }}: {{ zet.title -}}
</a>
</li>