Run the .php extension(or .shtml, or .asp, etc), code in .html file

Google strictly follow the .html or .htm extension when it indexed your website if it find the .php extension(or .shtml, or .asp, etc), it execute your web page before indexed by this way your website server will be busy and also the best SEO(search engine optimization) file is .html or .htm file.

This Process could be done by many ways
The first way is you can use iframe in the .html file and call the .php file but it is a long process and also not for who have already incoming links or search engine ranking so you don’t want to change the file name. What can you do?

First let me preface this by saying that if you are creating a new file anyway, you may as well use .php. This is to help people who have existing .html pages they need to execute PHP on.

The way to execute PHP on a .html page is to modify your .htaccess file. This file may be hidden, so depending upon your FTP program you may have to modify some settings to see it. Then you just need to add this line
for .html:
AddType application/x-httpd-php5 .html
Or for .htm
AddType application/x-httpd-php5 .htm

If you only plan on including the PHP on one page, it is better to setup this way:

AddType application/x-httpd-php5 .html .htm

This code will only make the PHP executable on the yourpage.html file, and not on all of your html pages.

These are the ways by which You can run PHP code or any other language code into .html file or any extension. By this nobody could know which language you are using and the another benefit is anybody could not write any malware in your script because he don’t know which language(any server side) you are using in your file.


  • If you have .htaccess file in your directory so only add this rule in your file and if you do not have .htaccess file in your directory you can create it by .htaccess extension and upload the file after uploading rename the file into .htaccess
  • The permission of .htaccess file is depend on the server, if you are not able to create .htaccess file then tere might be a problem due to server Restrictions, You can resolve this by the help of webmaster.

To Download(in rar format) .htaccess file kindly click here

Share This Post

One Response to "Run the .php extension(or .shtml, or .asp, etc), code in .html file"

Post Comment