One hit our inbox support most common problem is how to make PHP work of * .html and * .htm files. With this blog, we try to provide practical guidance for our users, and thus kill two birds with one stone metaphor.

One problem: my virtual host support PHP?

First, you should try to find our whether PHP is not supported by your web host or. If you already know PHP can continue to ask questions second reading. If you do not know you can either ask your hosting company, or you can just try the following steps:

First, create a file named “phptest.php” file. At this stage, use the file extension “of .php” is important. Open a simple text editor, a file (such as “Edit” in Windows) and write the following line:

<? PHP echo “Hello World”;? >
After saving the file, upload it to the root directory of your webspace. Open a browser and go directly to the file you just uploaded: “http://www.your-domain.com/phptest.php” (Needless to say, you should use your own domain name here …)

This is the truth of the moment. What is a browser say? If you see the words “Hello World” is all well and good, PHP work. But if you do not see these, please contact your hosting provider, because PHP does not work (yet). Most hosting companies offer packages include PHP. So maybe you just need to switch to another hosting plan.

Second problem: how to make PHP work in HTML files?

If PHP work there is only one step left to use PHP script files *. html or * .htm extension also. The magic word is “the .htaccess”. See the definition of .htaccess Wikipedia, to learn more about it. According to Wikipedia is “directory-level configuration file, which allows Web server configuration decentralized management.”
You may be able to use such a configuration of the .htaccess file, your purpose. In our example, you want the web server to parse HTML files, such as PHP files.
First, create a blank text file and name it “the .htaccess”. Why is the file name to point you might be asking yourself. In Unix-like systems, which means it is a point file is hidden.
(Note: If your operating system does not allow file names to point to the file name “xyz.htaccess” temporarily as long as you upload it to your Web server in a later step, you can rename the file online, “the .htaccess”)
Next, open the file, as in MS Windows “Edit” a simple text editor. Paste the following lines to the file:
The AddType application / X of httpd – PHP of the .htm .html

If this does not work, remove the line from the file above, this alternative line pasted into it for PHP5:
The AddType application / X of httpd-PHP5 of the .htm .html
Now .htaccess file upload to the root directory of your web server. Ensure that the name of the file is “htaccess of.” Your server should now be analyzed * .htm and * .html files, such as PHP files.

You can try, if it works is to create an HTML file is shown below. Name it “PHP- in the HTML TEST.HTM”, paste the following code into it, and upload it to the root directory of your Web server:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
	<TITLE>Use PHP in HTML files</TITLE>
	</HEAD>
 
	<BODY>

<h1>
		<?php echo "It works!"; ?>
		</h1>

	</BODY>
</HTML>

Try to open by typing in the browser files: http: //www.your-domain.com/php-in-html-test.htm (again, please substitute your own domain name your-domain.com … )

If your browser displays the phrase, “It works!” Everything is working properly, you can use PHP *. html and * .htm files from now. But, if not, try using an alternative route as we .htaccess file shown above. If this does not work, please contact your hosting provider.