{"id":562,"date":"2013-02-08T14:09:13","date_gmt":"2013-02-08T14:09:13","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2013\/02\/08\/php-code-in-html-file\/"},"modified":"2024-10-10T11:35:04","modified_gmt":"2024-10-10T15:35:04","slug":"php-code-in-html-file","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/","title":{"rendered":"How to enable html files to display php code"},"content":{"rendered":"<p>Explore the versatility of <a href=\"https:\/\/www.inmotionhosting.com\/php-hosting\">hosting php<\/a>: a step-by-step guide for enabling HTML files to display php code via .htaccess.<\/p>\n<p>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 <em>.html or .htm<\/em>) or php (files ending in the extension <em>.php<\/em>) 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.<\/p>\n<h2>Enabling HTML files to display php code<\/h2>\n<ol class=\"article_list\">\n<li><a href=\"\/support\/edu\/cpanel\/how-to-log-into-cpanel\/\" target=\"_blank\" rel=\"noopener noreferrer\">Log into your cPanel<\/a> dashboard.<\/li>\n<li><a href=\"\/support\/edu\/cpanel\/using-file-manager-in-cpanel\/\" target=\"_blank\" rel=\"noopener noreferrer\">Use the File Manager<\/a> to navigate to the root folder for the domain you are working with, ensuring you set the <a href=\"\/support\/website\/show-hidden-files-in-file-manager\/\">Show Hidden Files<\/a> option.<\/li>\n<li>Once in the root folder for the domain, <a href=\"\/support\/website\/where-is-my-htaccess-file\/\" target=\"_blank\" rel=\"noopener noreferrer\">check for the <em>.htaccess<\/em> file<\/a>. If one is not there, you will need to <a href=\"\/support\/website\/create-new-file\/\">create a new one<\/a>. Once located, <a href=\"\/support\/website\/how-to-edit-a-file\/\">edit the file<\/a> by highlighting the file and click on the <strong>Edit<\/strong> icon from the toolbar at the top of the page.<\/li>\n<li>This brings you to the cpanel file editor. You will want to insert the following line of code at the top of the <em>.htaccess <\/em>file.<code>AddType text\/html .shtml .shtm .htm .html<br>\nAddHandler server-parsed .shtml .shtm .htm .html<br>\nOptions Indexes<br>\nFollowSymLinks<br>\nIncludes # Uncomment the version of PHP you have on your server<br>\n# Only one of the following\u00a0 can be uncommented<br>\nAddHandler application\/x-httpd-imh-php56 .html<br>\n#AddHandler application\/x-httpd-imh-php70 .html<br>\n#AddHandler application\/x-httpd-imh-php71 .html<br>\n#AddHandler application\/x-httpd-imh-php72 .html<br>\n#AddHandler application\/x-httpd-ea-php72 .html <!--AddHandler application\/x-httpd-php5 .shtml--><\/code>\n<p class=\"alert\"><strong>Important!<\/strong> You will need to <a href=\"\/support\/website\/update-local-php-settings\/\" target=\"_blank\" rel=\"noopener noreferrer\">check your php version<\/a> so you know which line to comment in the previous code.<br>\nIf you\u2019re running <strong>8.1+<\/strong>, then comment out:<br>\n<code>FollowSymLinks<br>\nIncludes # Uncomment the version of PHP you have on your server<\/code><\/p><\/li>\n<li>Click the <strong>Save Changes<\/strong> 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.<br>\n<table class=\"article_table\">\n<tbody>\n<tr>\n<th>Before<\/th>\n<th>After<\/th>\n<\/tr>\n<tr>\n<td><a href=\"\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png\" rel=\"lightbox-0\"><img decoding=\"async\" width=\"753\" height=\"130\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png\" class=\"optimized-lcp-image\" alt=\"before htaccess code edit\" loading=\"eager\" fetchpriority=\"high\" sizes=\"(max-width: 768px) 100vw, 768px\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png 753w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before-300x52.png 300w\"><\/a>\n<div style=\"clear: both;\"><\/div>\n<\/td>\n<td><a href=\"\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-after.png\" rel=\"lightbox-0\"><img loading=\"lazy\" decoding=\"async\" class=\"std_ss\" style=\"max-width: 250px;\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-after.png\" alt=\"after htaccess code edit\" width=\"754\" height=\"134\"><\/a>\n<div style=\"clear: both;\"><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>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, particularly on Linux servers like the ones used for our hosting accounts, are either generally either HTML (files ending in the extension .html or<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/\"> Read More ><\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4288],"tags":[],"class_list":["post-562","post","type-post","status-publish","format-standard","hentry","category-website"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to enable html files to display php code | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Looking to get php to display in your html files? Learn how adjust your .htacess file to allow it with this article.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to enable html files to display php code | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Looking to get php to display in your html files? Learn how adjust your .htacess file to allow it with this article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2013-02-08T14:09:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-10T15:35:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png\" \/>\n<meta name=\"author\" content=\"Scott Mitchell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Scott Mitchell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/\"},\"author\":{\"name\":\"Scott Mitchell\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\"},\"headline\":\"How to enable html files to display php code\",\"datePublished\":\"2013-02-08T14:09:13+00:00\",\"dateModified\":\"2024-10-10T15:35:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/\"},\"wordCount\":351,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png\",\"articleSection\":[\"Website\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/\",\"name\":\"How to enable html files to display php code | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png\",\"datePublished\":\"2013-02-08T14:09:13+00:00\",\"dateModified\":\"2024-10-10T15:35:04+00:00\",\"description\":\"Looking to get php to display in your html files? Learn how adjust your .htacess file to allow it with this article.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#primaryimage\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png\",\"width\":753,\"height\":130,\"caption\":\"before htaccess code edit\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to enable html files to display php code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\",\"name\":\"Scott Mitchell\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to enable html files to display php code | InMotion Hosting","description":"Looking to get php to display in your html files? Learn how adjust your .htacess file to allow it with this article.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/","og_locale":"en_US","og_type":"article","og_title":"How to enable html files to display php code | InMotion Hosting","og_description":"Looking to get php to display in your html files? Learn how adjust your .htacess file to allow it with this article.","og_url":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2013-02-08T14:09:13+00:00","article_modified_time":"2024-10-10T15:35:04+00:00","og_image":[{"url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png","type":"","width":"","height":""}],"author":"Scott Mitchell","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Scott Mitchell","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/"},"author":{"name":"Scott Mitchell","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed"},"headline":"How to enable html files to display php code","datePublished":"2013-02-08T14:09:13+00:00","dateModified":"2024-10-10T15:35:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/"},"wordCount":351,"commentCount":7,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png","articleSection":["Website"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/","url":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/","name":"How to enable html files to display php code | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#primaryimage"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png","datePublished":"2013-02-08T14:09:13+00:00","dateModified":"2024-10-10T15:35:04+00:00","description":"Looking to get php to display in your html files? Learn how adjust your .htacess file to allow it with this article.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#primaryimage","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2013\/02\/edu_htaccess_display-php-in-html_display-before.png","width":753,"height":130,"caption":"before htaccess code edit"},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/php-code-in-html-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to enable html files to display php code"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed","name":"Scott Mitchell","url":"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=562"}],"version-history":[{"count":7,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/562\/revisions"}],"predecessor-version":[{"id":128716,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/562\/revisions\/128716"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}