Thanks to this forum I could make it work... almost. What I can't seem to get right is to force the slash at the end like in http://domain.tld/page/
My page is http://jonathangubler.ch - here's what I have in my .htaccess:
- Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# Remove /index.html
RewriteCond %{THE_REQUEST} \ /(.+/)?index\.html(\?.*)?\ [NC]
RewriteRule ^(.+/)?index\.html$ /%1 [R=301,L]
# Remove www.
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,L]
# Remove .html
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule ^(.+)\.html$ /$1 [R=301,L]
# Add .html back.
RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule ^(.*[^/])$ /$1.html [QSA,L]