php - 使用 .htaccess 进行 PHP 设置时出现 500 Internal Server Error

标签 php .htaccess

当我对以下 PHP 设置使用 .htaccess 时,我在访问该网站时遇到 500 Internal Server Error

.htaccess 文件中的代码:

php_flag display_errors off
php_flag log_errors on

.htaccess 文件权限为 644

我知道上面的代码是正确的。但是当它向我显示 500 Internal Server Error 时,我也尝试了不同的代码(很可能是错误的),但没有任何效果。尝试的不同代码是:

php_value display_errors off
php_value log_errors on

php_value display_errors 0
php_value log_errors 1

500 Internal Server Error 的原因是什么?

从这个问题的评论中了解到,我发现 .htaccess 上的 PHP 设置不适用于 FastCGI。因此,要更改 PHP 设置,我需要修改 php.ini 或者我需要在 php 代码中进行修改。当我无权修改 php.ini 文件并且我不想单独修改所有 PHP 文件时,有没有其他方法?

最佳答案

就像上面的评论所说:您需要将 php 模块作为 Dynamic Shared Object 运行使其工作,如 Apache PHP Request Hanlding Documentation 中所述

DSO considerations:

libphp provides Apache directives such as php_$value and php_admin_$value. DSO is the only option where these directives will be valid inside .htaccess files or httpd.conf. When these directives are compiled with the concurrent DSO patch, they should be named php4_$value and php5_$value instead.

cgi, fcgi, suphp 都不行。

关于php - 使用 .htaccess 进行 PHP 设置时出现 500 Internal Server Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10928328/

相关文章:

linux - 如何在子目录上使用.htaccess deny from all

.htaccess - htaccess 替换url中的参数

php - MySQL INNER 加入 RIGHT 加入和多条件 WHERE 子句与 FULL TEXT

php - PHP中如何解析<a>标签的属性值

php - SilverStripe - 根据下拉选择创建分页

php - htaccess 在一台服务器上工作正常并在另一台服务器上导致重定向循环

PHP,未捕获类型错误 : Cannot read property 'length' of undefined

php - Symfony 在生产中禁用 Controller 操作

.htaccess - 使用Errordocument 401会导致空白页

.htaccess - MAMP localhost 无法启用 CORS