This topic contains 0 replies, has 1 voice, and was last updated by CatWiki 1 year, 4 months ago.
March 30, 2017 at 5:46 pm #180
If you have a website that is based on HTM/HTML files, then you know that including PHP code in these files does nothing. And changing your web pages to .php is also no recommended for an established website – losing any SEO value up to the point of the change.
Luckily running PHP code in HTM/HTML files can be done with a simple command that tells the server to also run php code in .htm/.html files. You need to include the following command line in your .htaccess file available in the root folder of your website
AddType application/x-httpd-php .html .htm
How to do that?
1. go to the root folder of your website with a FTP program or WebFTP from your hosting account
2. find the .htaccess file and download it on your PC
3. open the .htaccess file with Notepad
4. copy the above line of code and paste it on a new line in the .htaccess file
5. save the file and upload it back to your server, overwriting the older file
Go to you website and check the htm/html page where you included the php code to see if it works.
PS: if you do not have a .htaccess file in the root folder of your file do this:
1. create a htaccess.txt file with your notepad
2. copy and paste the above line of code in the file
3. save the file and upload it to your server where your website is
4. rename on the server the file from “htaccess.txt” to “.htaccess”
Note 1: Please note that the website should be hosted on a linux/apache server (which is more than likely; shared hosting accounts are more than likely to be linux/apache).
Note 2: The above code might not work on all shared hosting because of their own in-house settings. But if this doesn’t work, check your hosting provider’s FAQ/Help section as it will surely show you the code that needs implemented in the .htaccess file. If you don’t find it, just contact them and you will surely get the correct code to use.
Alternative codes to be used/tested:
AddType application/x-httpd-php5 .html .htm– if your PHP version is 5
AddHandler x-mapp-php5 .html .htm– for 1and1 hosting
- This topic was modified 1 year, 4 months ago by CatWiki.
You must be logged in to reply to this topic.