Could anyone advise on the best/most efficient way to re-write .htm and .html pages to .php?
So if test.htm is requested, it actually serves test.php
Thanks
topr8
10:43 pm on Dec 10, 2012 (gmt 0)
any reason why you want to rewrite them rather than just parse .htm as php?
Karma
10:49 pm on Dec 10, 2012 (gmt 0)
Hi,
I don't think so, in all honesty I'm not sure - I thought that was the only way to do it :/
I've recently taken over an old website that has only .htm pages, so I'm planning to develop a PHP site and don't want to lose the .htm URLs that have been in place for years.
lucy24
11:00 pm on Dec 10, 2012 (gmt 0)
The answer to your original question is "Yes, but." ;)
topr8
11:37 pm on Dec 10, 2012 (gmt 0)
>>I've recently taken over an old website that has only .htm pages, so I'm planning to develop a PHP site and don't want to lose the .htm URLs that have been in place for years.
in which case you just want to set the server to parse .htm as php
in .htaccess something like
AddHandler application/x-httpd-php .htm
this way keep using the original files but they will act just like a php file
Karma
11:39 pm on Dec 10, 2012 (gmt 0)
Thanks. Just wondering, what is the difference between the two ?
topr8
10:03 am on Dec 11, 2012 (gmt 0)
in the rewrite, the server receives the request for example.htm and instead of serving example.htm will serve example.php
in the other example, it serves example.hem and executes any php code that is in that file.
for my mind the second way is more elegant, if for no other reason, should you forget to make a new .php file for one of the old ones the page will still work - assuming the files are still on the server, whereas with the rewrite you'll get an error page
g1smd
10:16 am on Dec 11, 2012 (gmt 0)
Yes. You don't need a rewrite, you just need to set things up so that your .htm files are parsed for PHP scripting within.