htaccess php_value auto_prepend_file给了我内部500错误

时间:2018-07-01 08:19:15

标签: .htaccess

我在 htaccess 中使用php_value auto_prepend_file时遇到问题。它给了我500 Internal Server Error。以下htaccess代码在localhost上正常运行,但在联机服务器上却给我500 Internal Server Error。问题出在哪里,解决方案是什么?任何人都可以在这方面帮助我吗?

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"

1 个答案:

答案 0 :(得分:2)

要使ast.parse指令起作用,必须在将PHP作为模块加载到Apache Web服务器的环境中。

不一定是这种情况。例如,您的在线服务器可以通过FCGI将PHP请求转发给FPM-worker,而无需在Apache中启用php_value

您可以将仅包含mod_php的文件放在服务器上,以检查是否是这种情况。对我来说,它然后在第三行显示phpinfo()

在这种情况下,无法通过Server API FPM/FastCGI覆盖php.ini设置。您唯一的选择是更改FPM / Pool配置(如果您可以访问它)或尝试.htaccess

编辑:也可以使用.user.ini文件作为替代:https://medium.com/@jacksonpauls/moving-from-mod-php-to-php-fpm-914125a7f336 / https://secure.php.net/manual/en/configuration.file.per-user.php-谢谢@anubhava