使用 .htaccess 使所有 .html 页面作为 .php 文件运行? [英] Using .htaccess to make all .html pages to run as .php files?
本文介绍了使用 .htaccess 使所有 .html 页面作为 .php 文件运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将所有 .html 文件作为 .php 文件运行,而且我没有时间在明天的演示之前更改所有链接.有什么办法可以用我的 Apache 服务器破解"这个吗?
I need to run all of my .html files as .php files and I don't have time to change all of the links before our presentation tomorrow. Is there any way to "hack" this with my Apache server?
推荐答案
在您网站的根目录创建一个 .htaccess 文件并添加以下行:
Create a .htaccess file at the root of your website and add this line:
[Apache2 @ Ubuntu/Debian: 使用这个指令]
[Apache2 @ Ubuntu/Debian: use this directive]
AddType application/x-httpd-php .html .htm
或者,来自下面的评论:
Or, from comment below:
AddType application/x-httpd-php5 .html .htm
如果您将 PHP 作为 CGI 运行(可能不是这种情况),您应该改为编写:
If your are running PHP as CGI (probably not the case), you should write instead:
AddHandler application/x-httpd-php .html .htm
这篇关于使用 .htaccess 使所有 .html 页面作为 .php 文件运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文