How to run PHP scripts in HTML files

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff. When a webpage is accessed, the server determines how to handle the Page Based on the file extension. Generally, when the file extension is htm or html, the server displays the file directly to the browser without any processing. If the extension is detected to be PHP, shtml, ASP, or JSP

Welcome to the Linux community forum and interact with 2 million technical staff> when you access a webpage, the server determines how to handle the Page Based on the file extension. Generally, when the file extension is htm or html, the server displays the file directly to the browser without any processing. If the extension is detected to be PHP, shtml, ASP, or JSP

Welcome to the Linux community forum and interact with 2 million technicians>

When you access a webpage, the server determines how to process the Page Based on the file extension. Generally, when you check that the extension is htm or html, the server displays the file directly to the browser, no processing is performed. If files with extensions such as PHP, shtml, ASP, or JSP are detected, the server first parses these files into html code and then presents the code to the processor.

The problem here is: when you encounter a good PHP script that you want to use on your website, and your website has generated static pages, and has a good ranking in the search engine, in this case, you certainly do not want to change the file to the php extension. What should I do?

First, open the htaccess file and add the following line of html code:

AddType application/x-httpd-php. html

Or

AddType application/x-httpd-php. htm

If you only want to include a php script on a page, you can set it as follows:

  

AddType application/x-httpd-php. html

  

After this configuration, only the uncletoo.html file can execute the php script.

Note:

1. Add content in the htaccess file instead of overwriting content

2. In any case, the program is from

   ';?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.