网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网络赚钱 > 网赚研究院
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

网赚研究院 研究网络赚钱、电子商务的新技术、动态。

Reply
 
Thread Tools Display Modes
  #1   IP: 218.2.39.83
Old 2007-08-21, 09:05 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default .html文件中运行php代码

How can I execute PHP code on my existing myfile.html page?

When a web page is accessed, the server checks the extension to know how to handle the page. Generally speaking if it sees a .htm or .html file, it sends it right to the browser because it doesn't have anything to process on the server. If it sees a .php extension (or .shtml, or .asp, etc), it knows that it needs to execute the appropriate code before passing it along to the browser.

Here is the problem: You find the perfect script, and you want to run it on your site, but you need to included PHP on your page for it to work. You could just rename your pages to yourpage.php instead of yourpage.html, but you already have 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:

Quote:
AddType application/x-httpd-php .html
Or for .htm

Quote:
AddType application/x-httpd-php .htm
If you only plan on including the PHP on one page, it is better to setup this way:

Quote:
AddType application/x-httpd-php .html
This code will only make the PHP executable on the yourpage.html file, and not on all of your html pages.
Reply With Quote
  #2   IP: 218.2.39.83
Old 2007-08-21, 11:05 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

对于Hostgator 以及 hostmonster空间:

问:How can I execute php code as .htm or .html files ,即如何让.htm文件中的php代码执行

答:In your .htaccess file insert this line of code.
Quote:
AddType application/x-httpd-php .html .htm .php
AddHandler application/x-httpd-php .html .htm .php
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 3 (0 members and 3 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is On

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:46 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.