DirectoryIndex index.html RewriteEngine On RewriteBase /noema/ # One canonical URL per page: the index at the directory, pages without an # extension. The .html and trailing-slash forms redirect. RewriteRule ^index\.html$ /noema/ [R=301,L] RewriteCond %{THE_REQUEST} \s/+noema/([a-z0-9-]+)\.html(?:[?\s]|$) [NC] RewriteRule ^([a-z0-9-]+)\.html$ /noema/$1 [R=301,L] RewriteRule ^([a-z0-9-]+)/$ /noema/$1 [R=301,L] # Serve pages from their .html files. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^([a-z0-9-]+)$ $1.html [L]