---
title: "How to enable html files to display php code"
description: "Explore the versatility of hosting php: a step-by-step guide for enabling HTML files to display php code via .htaccess. When creating your own site, you have many options. The basic files,..."
url: https://www.inmotionhosting.com/support/website/php-code-in-html-file/
date: 2013-02-08
modified: 2024-10-10
author: "Scott Mitchell"
categories: ["Website"]
type: post
lang: en
---

# How to enable html files to display php code

Explore the versatility of [hosting php](https://www.inmotionhosting.com/php-hosting): a step-by-step guide for enabling HTML files to display php code via .htaccess.

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](/support/edu/cpanel/how-to-log-into-cpanel/) dashboard.
2. [Use the File Manager](/support/edu/cpanel/using-file-manager-in-cpanel/) to navigate to the root folder for the domain you are working with, ensuring you set the [Show Hidden Files](/support/website/show-hidden-files-in-file-manager/) option.
3. Once in the root folder for the domain, [check for the *.htaccess* file](/support/website/where-is-my-htaccess-file/). If one is not there, you will need to [create a new one](/support/website/create-new-file/). Once located, [edit the file](/support/website/how-to-edit-a-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 AddHandler application/x-httpd-php5 .shtml` **Important!** You will need to [check your php version](/support/website/update-local-php-settings/) so you know which line to comment in the previous code. If you’re running **8.1+**, then comment out: `FollowSymLinks Includes # Uncomment the version of PHP you have on your server`
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 After [![before htaccess code edit](https://www.inmotionhosting.com/support/wp-content/uploads/2013/02/edu_htaccess_display-php-in-html_display-before.png)](/support/wp-content/uploads/2013/02/edu_htaccess_display-php-in-html_display-before.png) [![after htaccess code edit](https://www.inmotionhosting.com/support/wp-content/uploads/2013/02/edu_htaccess_display-php-in-html_display-after.png)](/support/wp-content/uploads/2013/02/edu_htaccess_display-php-in-html_display-after.png)
