Forum Moderators: phranque
On one of my sites I used the following in my .htaccess
RewriteRule ^([^.]+)\.htm$ $1.php [L]
I think that I remember that it rewrites both .htm and .html extensions.
What I'm wondering is, do all the file extensions in the site have to be changed, or if the server doesn't find foo.php, will it then serve foo.htm?
RewriteRule ^([^.]+)\.htm$ $1.php [L]I think that I remember that it rewrites both .htm and .html extensions.
No, that rule only rewrites .htm files.
What I'm wondering is, do all the file extensions in the site have to be changed, or if the server doesn't find foo.php, will it then serve foo.htm?
There's no magic here. If the requested file doesn't exist, then you get a 404-Not Found, unless there is some other 'agent' at work, such as another mod_rewrite rule, content negotiation, or an AcceptPathInfo setting. As this implies, what you describe *can* be done, but it doesn't happen automagically... :)
Taking a rather large step back from this problem, are you sure you need to 'rename' anything at all? You can tell your server to parse html files for PHP code if you want to...
Jim
RewriteRule ^([^.]+)\.htm$ $1.php [L]I think that I remember that it rewrites both .htm and .html extensions.
No, that rule only rewrites .htm files.
What I'm wondering is, do all the file extensions in the site have to be changed, or if the server doesn't find foo.php, will it then serve foo.htm?There's no magic here. If the requested file doesn't exist, then you get a 404-Not Found, unless there is some other 'agent' at work, such as another mod_rewrite rule, content negotiation, or an AcceptPathInfo setting. As this implies, what you describe *can* be done, but it doesn't happen automagically... :)
Taking a rather large step back from this problem, are you sure you need to 'rename' anything at all? You can tell your server to parse html files for PHP code if you want to...
Renaming is not such a big deal on this site, just so I know what all I need to do before loading the pages.
Thanks,
Dave