homepage Welcome to WebmasterWorld Guest from 54.211.97.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Rewrite .htm and .html pages to .php
Karma

5+ Year Member



 
Msg#: 4526717 posted 10:02 pm on Dec 10, 2012 (gmt 0)

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

 

topr8

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



 
Msg#: 4526717 posted 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

5+ Year Member



 
Msg#: 4526717 posted 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

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



 
Msg#: 4526717 posted 11:00 pm on Dec 10, 2012 (gmt 0)

The answer to your original question is "Yes, but." ;)

topr8

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



 
Msg#: 4526717 posted 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

5+ Year Member



 
Msg#: 4526717 posted 11:39 pm on Dec 10, 2012 (gmt 0)

Thanks. Just wondering, what is the difference between the two ?

topr8

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



 
Msg#: 4526717 posted 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

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4526717 posted 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

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