像 PHP 一样处理 HTML 文件 [英] Process HTML files like PHP

查看:26
本文介绍了像 PHP 一样处理 HTML 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 让 .html 文件像 .PHP 文件一样进行处理.htaccess 文件.我使用了以下内容,这两个方法都不起作用,尝试访问测试页面让我可以选择下载不存在的文件.我该如何解决这个问题?

I've been trying to get .html files to process like .PHP files, using the .htaccess file. I've used the following, both of which don't work and trying to access the test page gives me an option to download a file that doesn't exist. How can I fix this?

这两个我都试过了;

AddType application/x-httpd-php .html .htm

AddType application/x-httpd-php5 .html .htm

想法是允许包含在我的网页中,但仍然使用 .html 文件.

The idea is to allow includes in my web pages, but still using .html files.

下面是我的 .htaccess 文件中的更多代码,我不认为它与 addType 混淆,但我会发布它.

Below is some more code from my .htaccess file, I don't think it's messing with the addType, but I'll post it up.

## Hide .html extension
# To externally redirect /dir/foo.html to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).html [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.html
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [L]

1&1 IONOS 决定只允许我使用以下代码;

1&1 IONOS have decided to only allow me to do it with the following code;

AddHandler x-mapp-php5 .html .htm

推荐答案

需要添加

AddHandler application/x-httpd-php .html .htm

这篇关于像 PHP 一样处理 HTML 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆