« BFGs on a plane | Main | Shopify Changes Pricing - Community Not Happy »

2007.08.01

.htaccess settings for parsing PHP script in HTML

I have a simple website with a common header and footer hosted on www.netnation.com. Instead of duplicating the common bits on every page and creating a maintenance nightmare, I opted to use php include statements. The problem was I don't particulary want to bother users with the implementation details, so I want my URLs to end with ".html" (not ".php"). After racking my brains out and trying every combination I could find on Google, it turns out the following is the magic incarnation:

AddHandler php-script .html
Action php-script /cgi-bin/php

Put those lines in your .htaccess file (in every directory), and your embedded php script in .html files will be parsed correctly.

If anyone knows why this works and the other stuff doesn't, please feel free to educate me and future visitors by commenting.

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/t/trackback/198107/20526896

Listed below are links to weblogs that reference .htaccess settings for parsing PHP script in HTML:

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

Thanks! I couldn't find the htaccess details to work. This saved me a ton of redevelopment time. Thanks!
I found this site on net while browsing. You can have latest php scripts here on this site on a small monthly membership and site gets new content on a regular basis so you will be getting all that new content for free. Just have a look.

Post a comment

Comments are moderated, and will not appear on this weblog until the author has approved them.

If you have a TypeKey or TypePad account, please Sign In