homepage Welcome to WebmasterWorld Guest from 54.196.196.62
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
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




msg:4526719
 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




msg:4526731
 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




msg:4526733
 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




msg:4526738
 11:00 pm on Dec 10, 2012 (gmt 0)

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

topr8




msg:4526753
 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




msg:4526754
 11:39 pm on Dec 10, 2012 (gmt 0)

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

topr8




msg:4526880
 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




msg:4526881
 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