# Prevent Apache from returning a 404 error for a rewrite if a directory # with the same name does not exist. Options -MultiViews # Custom error message ErrorDocument 404 /404.html # Set your root directory RewriteBase / # Remove the .html extension RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP RewriteRule (.*)\.html$ $1 [R=301] # Remove index and reference the directory RewriteRule (.*)/index$ $1/ [R=301] # Remove trailing slash if not a directory RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} /$ RewriteRule (.*)/ $1 [R=301] # Forward request to html file, **but don't redirect (bot friendly)** RewriteCond %{REQUEST_FILENAME}.html -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.html [L]