# Enable the Rewrite Engine RewriteEngine On # If the requested file does not exist RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Check if a file exists with .php or .html extension RewriteRule ^([^\.]+)$ $1.php [L,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.html [L,NC] # Redirect to custom 404 page if the file still doesn't exist ErrorDocument 404 /404.php