Process HTML files like PHP(处理 HTML 文件,如 PHP)
问题描述
我一直在尝试使用 让 .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
这篇关于处理 HTML 文件,如 PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:处理 HTML 文件,如 PHP


基础教程推荐
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01