.htaccess 779 B

12345678910111213141516171819202122232425262728
  1. # Prevent Apache from returning a 404 error for a rewrite if a directory
  2. # with the same name does not exist.
  3. Options -MultiViews
  4. # Custom error message
  5. ErrorDocument 404 /404.html
  6. # Set your root directory
  7. RewriteBase /
  8. # Remove the .html extension
  9. RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP
  10. RewriteRule (.*)\.html$ $1 [R=301]
  11. # Remove index and reference the directory
  12. RewriteRule (.*)/index$ $1/ [R=301]
  13. # Remove trailing slash if not a directory
  14. RewriteCond %{REQUEST_FILENAME} !-d
  15. RewriteCond %{REQUEST_URI} /$
  16. RewriteRule (.*)/ $1 [R=301]
  17. # Forward request to html file, **but don't redirect (bot friendly)**
  18. RewriteCond %{REQUEST_FILENAME}.html -f
  19. RewriteCond %{REQUEST_URI} !/$
  20. RewriteRule (.*) $1\.html [L]