带有行 AddHandler php5-script .php 的 .htaccess 有什么作用? [英] what does .htaccess with line AddHandler php5-script .php do?

查看:24
本文介绍了带有行 AddHandler php5-script .php 的 .htaccess 有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用新的网络主机.我创建的每个域的 public_html 文件夹都是使用 .htaccess 自动生成的,其中包含以下行:

I am with new web host. The public_html folder of each domain I create is auto generated with an .htaccess that has the following line:

AddHandler php5-script .php

这是干什么用的?

推荐答案

这只是指示 PHP 通过将它们传递给 PHP5 解释器来处理以 .php 结尾的文件.如果没有此配置,Web 服务器可能会将文件作为原始 PHP 代码提供给最终用户的 Web 浏览器,而不是执行代码.这增加了暴露数据库登录凭据或其他机密的危险可能性.

This just instructs PHP to handle files ending in .php by passing them to the PHP5 interpreter. Without this configuration in place, the web server may serve the files to the end-user's web browser as raw PHP code, rather than executing the code. That raises the dangerous possibility of exposing database login credentials or, or other secrets.

使用相同的机制,您可以将 Web 服务器配置为将带有 .php 之外的其他扩展名的文件解析为 PHP 脚本,并将它们交给 PHP 解释器.例如,有时会通过使用 .html 扩展名命名 PHP 脚本来屏蔽 PHP 脚本.

Using the same mechanism, you could configure the web server to parse files with other extensions besides .php as PHP scripts and hand them to the PHP interpreter. This is occasionally done to mask PHP scripts by naming them with .html extensions, for example.

# Interpret both .php & .html as PHP:
AddHandler php5-script .php .html

这篇关于带有行 AddHandler php5-script .php 的 .htaccess 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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