# Force clean URLs (no ".html" extension) for all pages on this site,
# now and for any pages added later.

RewriteEngine On

# If someone requests /pagina.html directly, redirect the browser to
# /pagina (permanent redirect, so search engines only index the clean URL).
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=301,L]

# Internally serve /pagina.html when /pagina is requested, without
# changing what's shown in the browser's address bar.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^.]+)$ $1.html [NC,L]
