diff --git a/.htaccess b/.htaccess index 5762c3a..ccfec99 100644 --- a/.htaccess +++ b/.htaccess @@ -1,14 +1,16 @@ RewriteEngine On -# Remove .html extension from URLs -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^([^\.]+)$ $1.html [L] - -# Redirect .html URLs to clean URLs +# Redirect .html URLs to clean URLs (except index.html) RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC] +RewriteCond %1 !^index$ [NC] RewriteRule ^ /%1? [NC,L,R=301] +# Add .html extension to clean URLs +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !^.*\.(css|js|png|jpg|jpeg|gif|webp|svg|ico|pdf)$ [NC] +RewriteRule ^([^\.]+)/?$ $1.html [L] + # Handle 404 errors ErrorDocument 404 /index.html