Welcome to WebmasterWorld Guest from 54.211.86.24

Forum Moderators: Ocean10000 & incrediBILL & phranque

Rewrite .htm and .html pages to .php

   
10:02 pm on Dec 10, 2012 (gmt 0)

5+ Year Member



Hi,

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
10:43 pm on Dec 10, 2012 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



any reason why you want to rewrite them rather than just parse .htm as php?
10:49 pm on Dec 10, 2012 (gmt 0)

5+ Year Member



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.
11:00 pm on Dec 10, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



The answer to your original question is "Yes, but." ;)
11:37 pm on Dec 10, 2012 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



>>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
11:39 pm on Dec 10, 2012 (gmt 0)

5+ Year Member



Thanks. Just wondering, what is the difference between the two ?
10:03 am on Dec 11, 2012 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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
10:16 am on Dec 11, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved