PHP in .html and .htm files

Asked by:
mcgeady
Time:
2012-07-10 11:23 pm
Category:
How To
Hits:
447
I have added "AddHandler" lines to my .htaccess file (after beating my head on "AddType" lines, which should have worked), and whatever I do, I cannot get your Apache server to execute PHP in .html and .htm files. What do I need to do?

You must login before you can ask a follow up question.

You must login before you can submit an answer.

OTHER ANSWERS

0

ScottM
2012-07-11 1:54 pm
Hello mcgeady,

The issue was the Adrdtype code needed one minor tweak. Instead of the code reading:

AddType application/x-httpd-php .html

it needed to read as:

AddType application/x-httpd-php5 .html

The php5 was the trick as it is necessary for the php 5.x version. You were most certainly on the right path.

For best practice however, it is not advised to embed php code into html files. This causes the server to perform extra processing as it reads each and every html file and line of code in it as php. This practice is usually reserved for when there are already existing html files that need php to be added, but have search engine indexing, links and backlinks connected to it. Preserving the html file would be necessary.

It is best to simply make the file a .php file and code it the same way you would the html file. This way pure html files are not processed as php, speeding the site up a bit. In the end, however, it is entirely up to you.

I hope this answers your question. If you have any more questions or information specific to the issue please leave a comment below so we can further assist you.

Best Regards,
Scott M

You must login before you can post a comment about this answer.

Like this Question?

Have a Question?

If you need some help, submit your question to our Community! We guarantee a response within 60 minutes (8am - 9pm EST, Monday - Friday)

Recent Questions

  1. Wordpress 404 error
  2. email blocked from specific client
  3. WebCalendar Error While Logging On

Support Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.