使用 .htaccess 将 allow_url_fopen 添加到我的 php.ini
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3694240/
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
add allow_url_fopen to my php.ini using .htaccess
提问by Mick
I want to allow allow_url_fopen
on my server . I have asked my host and they said it can be done with a .htaccess
file. Can anyone tell me how to go about this ?
我想allow_url_fopen
在我的服务器上允许。我问过我的主人,他们说可以用.htaccess
文件来完成。谁能告诉我如何解决这个问题?
回答by Kranu
Try this, but I don't think it will work because you're not supposed to be able to change this
试试这个,但我不认为它会起作用,因为你不应该能够改变它
Put this line in an htaccess file in the directory you want the setting to be enabled:
将此行放在要启用设置的目录中的 htaccess 文件中:
php_value allow_url_fopen On
Note that this setting will only apply to PHP file's in the same directory as the htaccess file.
请注意,此设置仅适用于与 htaccess 文件位于同一目录中的 PHP 文件。
As an alternative to using url_fopen, try using curl.
作为使用 url_fopen 的替代方法,请尝试使用 curl。
回答by Syed Nurul Islam
allow_url_fopen
is generally set to On.
If it is not On, then you can try two things.
allow_url_fopen
一般设置为开。如果它没有打开,那么您可以尝试两件事。
Create an
.htaccess
file and keep it in root folder ( sometimes it may need to place it one step back folder of the root) and paste this code there.php_value allow_url_fopen On
Create a
php.ini
file (for update serverphp5.ini
) and keep it in root folder (sometimes it may need to place it one step back folder of the root) and paste the following code there:allow_url_fopen = On;
创建一个
.htaccess
文件并将其保存在根文件夹中(有时可能需要将其放在根文件夹的后退一步)并将此代码粘贴到那里。php_value allow_url_fopen On
创建一个
php.ini
文件(用于更新服务器php5.ini
)并将其保存在根文件夹中(有时可能需要将其放在根文件夹的后退一步)并将以下代码粘贴到那里:allow_url_fopen = On;
I have personally tested the above solutions; they worked for me.
以上方案我都亲自测试过;他们为我工作。
回答by Tim Green
If your host is using suPHP, you can try creating a php.ini
file in the same folder as the script and adding:
如果您的主机使用 suPHP,您可以尝试php.ini
在与脚本相同的文件夹中创建一个文件并添加:
allow_url_fopen = On
allow_url_fopen = On
(you can determine this by creating a file and checking which user it was created under: if you, it's suPHP, if "apache/nobody" or not you, then it's a normal PHP mode. You can also make a script
(您可以通过创建一个文件并检查它是在哪个用户下创建的来确定这一点:如果是您,则是 suPHP,如果是“apache/nobody”或不是您,则这是正常的 PHP 模式。您也可以制作脚本
<?php
echo `id`;
?>
To give the same information, assuming shell_exec
is not a disabled function)
为了提供相同的信息,假设shell_exec
不是禁用的功能)