Jump to content

Running PHP code in an HTML file


Recommended Posts

Hello,

 

I am trying to run PHP code in an HTML file. I wish to maintain the UX of my website by avoiding the .php extension on pages that my users see whenever possible.

 

For this reason, I am trying to find a way to run PHP within an HTML file. Upon doing research I found that it is possible to write a .htaccess file but was unsure what code to add to the .htaccess file so that it would work properly on Heliohost's servers (mine is Tommy).

 

For an Apache server for example, the .htaccess file to solve the issue would be :

 

AddType application/x-httpd-php .html

 

Please let me know the best way to achieve the desired functionality on Heliohost servers. Thanks.

Link to comment
Share on other sites

You change PHP versions and enable .html processing in .htaccess. A line similar to this may already exist if you used MultiPHP manager. In this case, add the .html to the end of the line.

AddType application/x-httpd-ea-php56 .php .php5 .phtml .html
 

(You can change the php56 portion to the version you want to use, we support php54, php55, php56, php70, php71, php72).

 

Note that directly modifying this line is incompatible with the MultiPHP manager in cPanel. If you do this, you should not attempt to set a PHP version with MultiPHP manager or it will delete your changes. This line will work in any folder too, so you can have different PHP versions or file extensions for different folders. The MultiPHP manager GUI is limited to per-domain settings only.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...