Rewrite .html to .php using mod_rewrite
html, mod-rewrite, php
Solution
For rewriting `.html` extensions to existing `.php` files with the same name, try this rule instead of what you had:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ $1.php?%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [L]
What you have just rewrites any non-existent file to index.php
Problem
I have a rewrite condition and rule which is. ``` RewriteCond %{DOCUMENT_ROOT}$0 !-f RewriteRule ^[^*]+$ index.php [L] ``` I need to replace `.html` with `.php` in `%{DOCUMENT_ROOT}$0`. The reason is, I am rewriting my url's to `.html` but when this file checks for an existing file it fails due to `%{DOCUMENT_ROOT}$0` looking for file `thefile.html`, I need it to look for `thefile.php`.