使用 .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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 10:44:14  来源:igfitidea点击:

add allow_url_fopen to my php.ini using .htaccess

php

提问by Mick

I want to allow allow_url_fopenon my server . I have asked my host and they said it can be done with a .htaccessfile. 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_fopenis generally set to On. If it is not On, then you can try two things.

allow_url_fopen一般设置为开。如果它没有打开,那么您可以尝试两件事。

  1. Create an .htaccessfile 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
    
  2. Create a php.inifile (for update server php5.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;
    
  1. 创建一个.htaccess文件并将其保存在根文件夹中(有时可能需要将其放在根文件夹的后退一步)并将此代码粘贴到那里。

    php_value allow_url_fopen On
    
  2. 创建一个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.inifile 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_execis not a disabled function)

为了提供相同的信息,假设shell_exec不是禁用的功能)