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
- Log into your cPanel dashboard.
- 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.
- 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.
- 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
- 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 |
|
|
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
new! - Enter your name and email address above and we will post your feedback in the comments on this page!