2012-12-24 35 views
1

我收到错误open_basedir的限制的.htaccess

Warning: fopen() [function.fopen]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (VIRTUAL_DOCUMENT_ROOT:/tmp/) in /www/elitno.net/s/p/anger2/home/site/classWebPage.php on line 83 

我的phpinfo文件是在这里 - >http://spaceranger2.elitno.net/phpinfo.php

其中错误是发生该生产线是在这里:

function openLink(){ 
    $this->fp = fopen($this->URL, "rb"); 
    array_shift($http_response_header); 
    $this->headers = $http_response_header; 
} 

我只能访问.htaccess,但不能访问我的php.ini文件;我试过用这个

open_basedir = "VIRTUAL_DOCUMENT_ROOT:/tmp/:/www/elitno.net/s/p/ranger2/home/site/" 

但这样会产生500 internal error的,有什么建议吗?

+0

你能分享的'$这个 - 值> URL'当错误出现?最有用的值将是'var_dump($ this-> URL)'的输出。 你也应该检查一下http://stackoverflow.com/a/2916429/964616。 –

+0

结果是字符串(1)“/” – user1905494

+0

解决方案是否适合您?如果是,请考虑将其标记为答案并且upvote。 –

回答

0

通常fopen只允许打开运行脚本的用户访问的文件。

您已设计了功能openLink()以实际打开特定的URL。您应该注意,使用fopen时,它实际上表示在磁盘上打开文件。如果您传递//filename.txt这样的值,实际上它将尝试打开文件系统路径上的文件。

从您的问题数据中,您要求fopen开放/。这是服务器文件系统的根。你的用户肯定无法访问它(因此你看到的错误)。

如果要打开一个到您网站的相对路径,请考虑在将网站网址前缀到$this->URL变量前,将其传递到fopen以表明您正在尝试打开网址。

你可以在以下的说法:

function openLink(){ 
    $siteURL = "http://www.example.com"; 
    $urlToOpen = $siteURL . $this->URL; 
    $this->fp = fopen($urlToOpen, "rb"); 
    array_shift($http_response_header); 
    $this->headers = $http_response_header; 
}