【发布时间】:2013-10-24 05:53:09
【问题描述】:
我一直在尝试使用 .htaccess 文件让 .html 文件像 .PHP 文件一样进行处理。我使用了以下,两者都不起作用,并且尝试访问测试页面让我可以选择下载不存在的文件。我该如何解决这个问题?
这两个我都试过了;
AddType application/x-httpd-php .html .htm
AddType application/x-httpd-php5 .html .htm
想法是允许包含在我的网页中,但仍使用 .html 文件。
下面是我的 .htaccess 文件中的更多代码,我认为它不会与 addType 混淆,但我会发布它。
## 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 已决定只允许我使用以下代码进行操作;
AddHandler x-mapp-php5 .html .htm
【问题讨论】:
-
您需要添加
AddHandler application/x-httpd-php .html .htm -
这对我也有帮助,由于某种原因,主机 LCN 也决定很难,只允许“AddHandler x-mapp-php5 .html .htm”。我会建议我的客户搬走!
标签: php html .htaccess include