RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]
This works for links like:
<a href="/subpagewithoutdash">working link (will link to subpagewithoutdash.html)</a>
But it doesn’t work for links with dash:
<a href="/subpage-with-dash">not working link (should link to subpage-with-dash.html)</a>
Any idea of how to fix it? I am sitting on a Windows computer with Xampp installed (localhost).
I can immediately think of two situations would cause this rule not to be applied:
subpage-with-dashis the name of a directory in the site root. This would trip theRewriteCondand cause the rule to be skipped.^([^\.]+)$) — excludes URLs that contain any periods. So, ifsubpage-with-dashis actuallysubpage-with-dash.something, the rule wouldn’t apply.