我问一个问题,如果我可以执行HTML文件,PHP文件和我得到这些问题的答案
i asked a question if i can execute html files as php files and i got those answers
AddType application/x-httpd-php5 .php .html
和另一个答案
AddHandler application/x-httpd-php .html .htm
和这里是另一个
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
和我有1问题 当我用来写任何条件添加一个类型它送我去下载页面,而不是运行 举例来说,如果我有一个index.html文件具有PHP code 之后,我创建的.htaccess写
and i got 1 problem when i used to write any condition to add type it send me to download the page instead of run it for example if i have a file index.html which have php code after i create the .htaccess and write
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
然后尝试导航链接发给我下载的index.html的,而不是来看,它
then try to navigate the link it send me to download index.html instead of run it
将AddType用于指定一个MIME类型文件的后缀。
AddType is used to assign a MIME type to a file suffix.
F.e。覆盖MIME类型的PDF *碳化硅
F.e. to override the MIME type of an PDF *sic
AddType text/plain .pdf
这将迫使浏览器加载和显示PDF为纯文本,因为服务器发送纯文本/ MIME类型。但是,许多应用程序将内容,而不是通过后缀处理文件。
This will force the browser to load and show a PDF as plain text, because server is sending the text/plain MIMe type. But many applications handle files by content and not by suffix.
RemoveHandler
这是不必要的,你不希望从标准配置中删除任何东西。
This is unnecessary, you don't want to remove anything from the standard configuration.
AddHandler handler-name .htm
这应该这样做,但是这取决于您的服务器配置。您需要正确的处理器名称。
This should do it, but it depends on your server configuration. You need the right "handler-name".
标准处理程序名称与安装了PHP最Apache的服务器是
Standard handler-name for most Apache servers with PHP installed is
AddHandler application/x-httpd-php .html
AddHandler application/x-httpd-php .htm
但也可能不同,这取决于您的配置。如果您使用的是共享或主机托管,而不访问Apache配置文件,你应该问你的主机供应商。
but it could differ and it depends on your configuration. If you are using a shared or managed hosting without access to the Apache configuration file, you should ask your hoster.
我是使用共享的主机与处理程序,名称,如
I was using shared hosting with handler-names like
AddHandler php4-cgi .php .html
or
AddHandler php52-cgi .php .html
and another was using totally different way like
AddType x-mapp-php5 .php .php5 .htm .html
否则有你的Apache配置文件看看。这页面可能有助于找到合适的部分,以适应。
Otherwise have a look on your Apache configuration file. This page may be helpful to find the right section and to adapt.