PHP in Blogger: In all Pages!
This is an alternate method to add PHP code to your blogger blog. This method works across all pages and not just the index page (contrary to the method outlined in the last post).
Add this line to your .htaccess file:
AddType application/x-httpd-php .htmlWhat this does is tells the webserver to process all html files as PHP files. This means that the web server will process any php code in the html files (just anything within <? ?> the tags ). So now you can add PHP code to you blogger template, and it will work universally throughout your blog - but you will take a performance hit (since even static html pages will not be parsed and processed as PHP code) and also a possible security risk (anything within <? ?> will now be executed as PHP code).
One option against this problem would be to restrict where this is to be applied, in your .htaccess file - as show below:
<Files index.html>
AddType application/x-httpd-php .html .htm
</Files>
<Files 200*>
AddType application/x-httpd-php .html .htm
</Files>
The above code restricts the treatment of html files as php to files with the name index.html and files with names that match the 200* pattern (the monthly archive html files).
I also recommend you go into your parent archives directory (the permanent links of posts are usually stored in an address along the line of "year/month/day/PostTitle" - the parent archive directory I refer to would be the "year" directory - this would be the directory by the name 2008 and/or 2009) and add the first code line from this post to the .htaccess file there.
AddType application/x-httpd-php .htmlThis would mean that all html files in that directory would get processed as if they were PHP files. This would cover the archived permanent links to the posts.
Voila. PHP in Blogger.
Important: It is important to realize the side-effects of these methods and then use this method if you feel it is okay. You might have to make changes to the above steps to match your blogger setup, this is the basic idea.


