处理 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
相关文章