.htaccess php_value auto_prepend_file makes a 500 error. How can I fix this?

My .htaccess looks like this:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /school
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1

php_value auto_prepend_file ./inc/library.php

ErrorDocument 404 /school/index.php?page=404

      

As in ./

, I read that indicates a relative path.

+3


source to share


2 answers


Note. This information was taken almost verbatim from another website , I thought it explained the problem well and I highly suspect it is the problem:


Using php_flag or php_value in .htaccess files

Some PHP scripts suggest using "php_value" or "php_flag" commands in .htaccess files, as in this example:

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 cannot use "php_value" or "php_flag" commands in .htaccess files. If you try to do this, you will see an "internal server error" message.

You can modify your php.ini file to get the same effect. In fact, changing php.ini is actually more flexible than using php_value or php_flag: there are many things that you cannot override using .htaccess files, but you can override almost any PHP setting in your php.ini file.

To get the same effect as .htaccess lines, you simply added these lines to your own php.ini file:

include_path = ".:/usr/local/lib/php" 
display_errors = Off
upload_max_filesize = 2M
auto_prepend_file = "./inc/library.php"

      

Note. Some systems will require quotation marks around paths, and some should not use quotation marks.

+8


source


You can use htscanner PHP module if you want to use php_value

in your .htaccess files when running php as CGI / FastCGI Application.



+3


source







All Articles