Home » Categories » Multiple Categories

Can I put PHP code in .html or .htm files?

You can run PHP code in .html/.htm files by changing the .htaccess file.

To change the .htaccess file:

  1. Back up your .htaccess file
  2. Open your .htaccess file or create one in a text editor
  3. At the end of the file, paste this code:

AddHandler cgi-script .html
SetEnv PHP_EXTENSION .html
AddHandler cgi-script .htm
SetEnv PHP_EXTENSION .htm

  1. Upload the new .htaccess file to your server
  2. PHP code will now run in .htm and .html files
1 (6)
Article Rating (6 Votes)
Rate this article
  • Icon PDFExport to PDF