When writing content for your site, you typically store them in either html or php files. HTML files are created with markup tags and these files are not processed or parsed by the server. Php files, on the other hand, are parsed and processed by the server before being displayed in html format to the client browser. Php files can also automatically use HTML code, however html files do not have the ability to process php code by default. This ability can be accomplished, however, by altering the .htaccess file in your hosting account.

How to enable HTML files to display php code

  1. Log into your cPanel dashboard.
  2. Using the File Manager, navigate to the root folder for the domain you want to work with. Also, be sure you set the Show Hidden Files option as you will be working with the .htaccess file.
  3. Now that you are in the root folder for the domain, locate the .htaccess file. If there is not one for the domain, you will need to create a new one. Once created or found, edit the file by highlighting the it and clicking on the Edit icon from the toolbar at the top of the page.
    click edit icon
  4. This brings you to the cpanel file editor. You will want to insert the following line of code at the top of the .htaccess file.
    AddType application/x-httpd-php5 .html .htm .php
  5. Click on the Save Changes button located in the upper right-hand corner of the screen. You are now able to place php code sections into your html files and have them display. Look at the before and after shot to see how the code affects a page with php in it.
    Before After
    page before code change page after code change
Did you find this article helpful?

Login to comment.

Your Opinion Matters

... but we need to know what you're thinking!

The Community Support team wrote the article you're looking at now. We like to think it's perfect, but we're sure you have some suggestions. Please, let us know what they are!

Feedback
Your Email Address
Because we'd like to talk with you!

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.