Skip to content

Instantly share code, notes, and snippets.

@renshuki
Last active March 18, 2019 13:27
Show Gist options
  • Save renshuki/1fbcc04e73b35f5bdb61ff6b01825d82 to your computer and use it in GitHub Desktop.
Save renshuki/1fbcc04e73b35f5bdb61ff6b01825d82 to your computer and use it in GitHub Desktop.
Apache rewrite configuration to delete .html extension in web page URL
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ $1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment