PHP in .html and .htm files

Asked by:
mcgeady / 18 Points
Time:
2012-07-11 2:23 am EST
Category:
How To
Hits:
900
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?

To ask this user for more information, please first login.

To submit an answer, please login.

ANSWERS

0

ScottM
Staff
16,266 Points
2012-07-11 4:54 pm EST
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

To submit a comment on this answer, please first login.

Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help 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.
}