PHP in HTML files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HisServant77
Forum Newbie
Posts: 1
Joined: Mon Feb 02, 2015 10:49 am

PHP in HTML files

Post by HisServant77 »

Hi everyone,

First off I'd like to apologize for my extreme lack of knowledge that I'll end up showing . . . just in the subject and question to begin with! I thank everyone for their patience and help with a matter I've run into!

I have a website:
workmenforChrist.org

Last weekend I went through and tried updating the wordpress section of my website. It was about 18 versions behind because I hate to admit, I neglected it. :( In the process of updating, I had to switch from php4, to php5. Now when I did this, though, I broke the rest of my website! My website is nearly 100% .html files, yet I use php includes to bring in my menu and a few other things. I did this via the .htaccess file.

Now, however, the php includes are not working! I tried getting my normally VERY helpful and knowledgeable webhost to help me out but it seems they didn't know and only kept telling me that I can't use php code in .html files. It was possible for the years I've had the website running perfectly fine. I have searched, and searched, and searched to no avail in finding what changed with php5 and what can be done (besides changing each and every file I have into a .php file). Every code snippet I have found that is supposed to allow php to be used in .html files to add to the .htaccess file, does not work for me at all. Is there anyone here who can please help me with this issue?

In my .htaccess file I have the following, which obviously does not work:

Code: Select all

RewriteEngine  on
SetEnv PHP_VERSION 5
#AddHandler cgi-script cgi PHP html

AddHandler x-http-php5-cgi .html

AddType text/html .shtml
AddHandler server-parsed .shtml
DirectoryIndex index.shtml index.html index.htm index.php
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?workmenforchrist.org/.*$ [NC]
RewriteRule \.(gif|jpg|png|mp3|mpg|avi|mov|js|css)$ - [F]

ErrorDocument 404 /404error.html

order allow,deny
deny from 200.63.42.136
allow from all
I truly appreciate the help, and your patience with me! I believe my webhost added and changed some lines in my file that I cannot recall WHY or when they did, so I really am unsure of all that is in there, only a handful of lines.

Thank you again, so much for any help possible!
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP in HTML files

Post by Celauran »

Can you list what you have tried so we don't offer up a bunch of solutions you already know don't work? What I've seen from a quick Google search suggests the following:

Code: Select all

AddHandler application/x-httpd-php .php
or

Code: Select all

AddType application/x-httpd-php .php
depending on whether the server is running PHP as an Apache module or CGI.
Post Reply