InMotion Hosting Support Center

When creating your own site, you have many options. The basic files, particularly on Linux servers like the ones used for our hosting accounts, are either generally either html (files ending in the extension .html or .htm) or php (files ending in the extension .php) files. HTML is the markup language for displaying content and is not processed on the server side. Php is a programming style language used to create pages that are processed and served from the server. Php files can always read and display HTML code, but HTML does not automatically parse php code. To do so, you will need to make adjustments to your .htaccess file. Once that is done, the php code will display within HTML files without issue. Follow the instructions below as they guide you on enabling html files to display php code via your .htaccess file.

Enabling HTML files to display php code

  1. Log into your cPanel dashboard.
  2. Use the File Manager to navigate to the root folder for the domain you are working with, ensuring you set the Show Hidden Files option.
  3. Once in the root folder for the domain, check for the .htaccess file. If one is not there, you will need to create a new one. Once located, edit the file by highlighting the file and click on the Edit icon from the toolbar at the top of the page.
  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 text/html .shtml .shtm .htm .html
    AddHandler server-parsed .shtml .shtm .htm .html 
    Options Indexes FollowSymLinks Includes
    # Uncomment the version of PHP you have on your server
    # Only one of the following  can be uncommented
    AddHandler application/x-httpd-imh-php56 .html
    #AddHandler application/x-httpd-imh-php70 .html
    #AddHandler application/x-httpd-imh-php71 .html
    #AddHandler application/x-httpd-imh-php72 .html
    #AddHandler application/x-httpd-ea-php72 .html

    Important! You will need to check your php version so you know which line to comment in the previous code.

  5. Click the Save Changes button in the upper right corner of the screen. Your html file should now display the php code within it. Below is a before and after shot of the effects of the .htaccess edit.
    before htaccess code edit after htaccess code edit
Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved. Please click the button below to be redirected to the login page.

n/a Points
2018-09-14 8:20 pm

Its not working with php 7   what to add to .htacess?

3,686 Points
2018-09-17 12:30 pm
I have updated the example code to include the correct syntax for PHP 7.0. You only need to uncomment the line that matches the version of PHP you are using. For PHP 7.0, your .htaccess file will look like the following:

AddType text/html .shtml .shtm .htm .html
AddHandler server-parsed .shtml .shtm .htm .html
Options Indexes FollowSymLinks Includes
# Uncomment the version of PHP you have on your server
# Only one of the following can be uncommented
AddHandler application/x-httpd-ea-php70 .shtml
#AddHandler application/x-httpd-php5 .shtml
#AddHandler application/x-httpd-php52 .shtml
#AddHandler application/x-httpd-php54 .shtml
#AddHandler application/x-httpd-php4 .shtml

I hope this helps!
n/a Points
2015-05-27 11:17 am

How do you do this if your server API is set to CGI/FastCGI?  I understand you need to use a php.ini file to do that but I can't find a similar tutorial on that file.

42,678 Points
2015-05-29 10:22 am
Hello Ryan,

Check out this FAQ -the PHP section. This is the closest thing that I could find that may provide the answer you're seeking. If you continue to have problems, please let us know.

Arnel C.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

5 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

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

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!