php .htaccess php_value auto_prepend_file 产生 500 错误。我怎样才能解决这个问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14885311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.htaccess php_value auto_prepend_file makes 500 error. How can I fix this?
提问by user2060274
My .htaccess is as follows:
我的 .htaccess 如下:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /school
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=
RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=
php_value auto_prepend_file ./inc/library.php
ErrorDocument 404 /school/index.php?page=404
As of the ./, I read that indicates a relative path.
从./,我读到表示相对路径。
回答by Wesley Murch
Note: This information was taken nearly verbatim from another website, I thought it explained the issue well and I highly suspect this is the problem:
注意:此信息几乎是从另一个网站逐字获取的,我认为它很好地解释了这个问题,我高度怀疑这就是问题所在:
Using php_flag or php_value in .htaccess files
在 .htaccess 文件中使用 php_flag 或 php_value
Some PHP scripts suggest using "php_value" or "php_flag" commands in .htaccess files, as in this example:
一些 PHP 脚本建议在 .htaccess 文件中使用“php_value”或“php_flag”命令,如下例所示:
php_value include_path ".:/usr/local/lib/php"
php_flag display_errors Off
php_value upload_max_filesize 2M
php_value auto_prepend_file "./inc/library.php"
However, some servers run PHP in "CGI mode" (not as an Apache module), so you can't use "php_value" or "php_flag" commands in .htaccess files. If you try to do so, you'll see an "internal server error" message.
但是,某些服务器以“CGI 模式”(不是作为 Apache 模块)运行 PHP,因此您不能在 .htaccess 文件中使用“php_value”或“php_flag”命令。如果您尝试这样做,您将看到“内部服务器错误”消息。
You can modify your php.ini file to get the same effect, though. In fact, modifying php.ini is actually more flexible than using php_value or php_flag: there are many things you can't override using .htaccess files, but you can override almost any PHP setting in the php.ini file.
不过,您可以修改 php.ini 文件以获得相同的效果。实际上,修改 php.ini 实际上比使用 php_value 或 php_flag 更灵活:使用 .htaccess 文件无法覆盖很多东西,但是几乎可以覆盖 php.ini 文件中的任何 PHP 设置。
To get the same effect as the .htaccess lines above, you would simply add these lines to your custom php.ini file:
要获得与上面的 .htaccess 行相同的效果,您只需将这些行添加到您的自定义 php.ini 文件中:
include_path = ".:/usr/local/lib/php"
display_errors = Off
upload_max_filesize = 2M
auto_prepend_file = "./inc/library.php"
Note: Some systems will require quotes around the paths, and some must not use quotes.
注意:有些系统需要在路径周围加引号,有些系统不能使用引号。

