how fix open_basedir issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
blogt
Forum Newbie
Posts: 2
Joined: Wed Nov 27, 2013 3:36 am

how fix open_basedir issue

Post by blogt »

Hi

I have loged error

[26-Nov-2013 08:28:46 UTC] PHP Warning: require(): open_basedir restriction in effect. File(/class/class.rewrite.php) is not within the allowed path(s): (/home/admin/domains/mydomain.com/public_html/:/tmp:/var/tmp:/usr/local/lib/php/:/home/admin/domains/mydomain.com/public_html/blog/) in /home/admin/domains/mydomain.com/public_html/blog/widget/index.php on line 10

How I should fix issue?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: how fix open_basedir issue

Post by requinix »

Seems like you have a

Code: Select all

require("/class/class.rewrite.php");
when you should have a

Code: Select all

require($_SERVER["DOCUMENT_ROOT"] . "/class/class.rewrite.php");
The key point is the use of DOCUMENT_ROOT. Without it, "/class/class.rewrite.php" means to look in the class folder in the root of the filesystem, which isn't allowed (hence the error) but not even what you want in the first place.
blogt
Forum Newbie
Posts: 2
Joined: Wed Nov 27, 2013 3:36 am

Re: how fix open_basedir issue

Post by blogt »

on line 10 I have this code:

require ($_SERVER["DOCUMENT_ROOT"]."/class/class.rewrite.php");
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: how fix open_basedir issue

Post by requinix »

Does it have a value?

Code: Select all

print_r($_SERVER);
DOCUMENT_ROOT looks like it is supposed to be /home/admin/domains/mydomain.com/public_html.

While you're in there, see if anything else looks wrong.
Post Reply