htaccess php_value auto_prepend_file gives me internal 500 error

Multi tool use
htaccess php_value auto_prepend_file gives me internal 500 error
I have a problem with php_value auto_prepend_file
from htaccess. It gives me 500 Internal Server Error. The following htaccess codes is working fine on localhost but gives me 500 Internal Server Error on online server. Where is the problem and what is the solution ? Anyone can help me in this regard please ?
php_value auto_prepend_file
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /script/
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} s/+(.+?).php[s?] [NC]
RewriteRule ^ %1 [R=302,NE,L]
RewriteCond %{THE_REQUEST} /index.php [NC]
RewriteRule ^(.*)index.php$ $1 [L,R=302,NC,NE]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^post/([w-]+)/?$ sources/post.php?msgID=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteRule ^(.+?)/?$ index.php?pages=$1 [L,QSA]
php_value auto_prepend_file "/home/*****/public_html/script/path.php"
File does not exist: /home/*****/public_html/404.shtml
Check answer below first. Your htaccess is not using Directory directive I believe.
– anubhava
Jul 1 at 8:41
@anubhava The error is this:
/home/******/public_html/script/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
– Azzo
Jul 1 at 8:49
/home/******/public_html/script/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
@anubhava The tobias-k answer means your bounty answer is not working everywhere . I have used your answer on my localhost.
– Azzo
Jul 1 at 8:57
1 Answer
1
For the php_value
directive to work it needs to be an environment where PHP is loaded as a module into the Apache webserver.
php_value
This is not necessarily the case. Your online server could for example forward PHP requests to a FPM-worker via FCGI, without mod_php
enabled in Apache.
mod_php
You may place a file with just a phpinfo()
in it on the server to check if that is the case. For me, it then displays Server API FPM/FastCGI
in the 3rd row.
phpinfo()
Server API FPM/FastCGI
In this case, overwriting php.ini
settings via .htaccess
is not possible. Your only options would be to change the FPM/Pool config (given you have access to that) or try ini_set
.
php.ini
.htaccess
ini_set
Edit: It may also be possible to utilize .user.ini files as an alternative: https://medium.com/@jacksonpauls/moving-from-mod-php-to-php-fpm-914125a7f336 / https://secure.php.net/manual/en/configuration.file.per-user.php - thanks @anubhava
I don't understood this part
Your only options would be to change the FPM/Pool config (given you have access to that) or try ini_set.
can you explain for me please ?– Azzo
Jul 1 at 9:04
Your only options would be to change the FPM/Pool config (given you have access to that) or try ini_set.
It meant to point out that it is possible to set non-global
php.ini
settings also in PHP-FPM, but not as easily as with mod_php
in Apache, where even a non-privileged user can do it just using a .htaccess
file. You would need to create a custom worker-pool (that then gets a unix-socket to connect to) and could use php_admin_value
there to change configuration per-pool. And of course it is always possible to use ini_set
in your PHP-code, but I realize for your auto_prepend_file
directive this may be too late.– Tobias K
Jul 1 at 9:12
php.ini
mod_php
.htaccess
php_admin_value
ini_set
auto_prepend_file
So that means i can not use it without your answer. So if you have a time can you check my bounthy question ? (HERE)[stackoverflow.com/questions/47801948/… i am using
php_value auto_prepend_file
because of the anubhavas' answer. His answer is working fine on every localhost. But not working online server– Azzo
Jul 1 at 9:17
php_value auto_prepend_file
also the error-log says this:
/home/******/public_html/script/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
– Azzo
Jul 1 at 9:17
/home/******/public_html/script/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
This is exactly the error you'd get in the situation I assume (
mod_php
not enabled): defined by a module not included in the server configuration Did you check phpinfo()
? What is the Server API?– Tobias K
Jul 1 at 9:22
mod_php
phpinfo()
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
@anubhava Dear there is not have any error about 500 error there is just this error:
File does not exist: /home/*****/public_html/404.shtml
– Azzo
Jul 1 at 8:34