studius Posted July 10, 2018 Posted July 10, 2018 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.
rajdis Posted July 11, 2018 Posted July 11, 2018 Place the PHP code in the HTML file as<?php<!-- Code -->?>And it will work.
wolstech Posted July 11, 2018 Posted July 11, 2018 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now