像PHP .htacess处理HTML文件 [英] .htacess Process HTML files like PHP

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

问题描述

我一直在试图让.html文件来处理像使用.htaccess文件.php文件,我用下面这两个不工作,并试图进入测试页面给我一个选择下载一个不存在的文件,任何想法?

试过这两种;

 将AddType应用/ X的httpd  -  PHP的。html的热媒

将AddType应用/的X的httpd-PHP5的.html的.htm
 

我们的想法是让包括我的网页,但仍在使用.html文件。

下面是我的.htaccess文件更多code,我不认为它搞乱了的addType,但我会后它。

  ##隐藏.html扩展
#要外部重定向/dir/foo.html到/ DIR /富
的RewriteCond%{THE_REQUEST} ^ [AZ] {3,} \ S([^。] +)\。HTML [NC]
重写规则^%1 [R,L,NC]

##在内部重定向/ DIR /富到/dir/foo.html
的RewriteCond%{} REQUEST_FILENAME html的-f
重写规则^%{REQUEST_URI}的.html [L]
 

___________EDIT____________________________-

的1and1已经决定只让我用低于code做到这一点;

 的AddHandler的X MAPP-PHP5的.html的.htm
 

解决方案

您需要添加

  AddHandler的应用程序/ X的httpd  -  PHP的。html的热媒
 

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, any ideas?

Tried both of these;

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

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

The Idea is to allow includes in my web pages but still using .HTML files.

Below is some more code from my .htaccess file, I don't think its 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]   

___________EDIT____________________________-

1and1 have decided to only allow me to do it with the below code;

AddHandler x-mapp-php5 .html .htm  

解决方案

You need to add

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

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

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