I inherited an existing site that was built as a bunch of static HTML files.
I wanted to add a footer (or sub footer) to them without needing to edit something like 50 files.
I was familiar with Apache being able to append a file, but I hadn't used it much so I had to hack away at it until I got it working right.
First thing. I had to get my *.htm files to be treated like PHP files. (get the server to parse them)
Guides online alternatively suggest AddType, AddHandler or a combination of the two.
I am hosted at HostGator and they suggested
AddHandler application/x-httpd-php54 .html .htm
be added to the .htaccess file.
There's one problem down.
I saw conflicting information about whether auto_append_file is allowed in the .htaccess file. I kept getting 500 Internal Server error when I tried it, so I moved it to php.ini
Here's the line I put in there:
auto_append_file = '/home/[MY USER'S USERNAME]/public_html/sub_footer.php'
Then formatted my subfooter to fit properly at the bottom of all the existing pages.
SUCCESS!
I should point out that this is not an ideal solution, but rather a quick and dirty work around until I can actually re-build the site in php. You're likely to run into exceptions and edge cases if you try to use this on an ongoing basis.
No comments:
Post a Comment