I'm trying to run a script on my shared hosting account, I keep getting an error relating to open_basedir, which I understand would normally be turned off in the php.ini file, which I don't have access to.

Speaking with the host they recommended that I put this line php_flag open_basedir off in my .htaccess file, so it now looks like this:

<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
AuthUserFile /var/www/vhosts/mydomain.co.uk/httpdocs/pri/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user 
order deny,allow

php_flag open_basedir off

But I still cant get the script to run, have I implemented it correctly? Is there a line in the phpinfo() output that I can view to tell if its worked?

  • No access to php.ini? What kind of medieval hosting service is this?
    – wogsland
    Feb 18, 2017 at 3:01

1 Answer 1


I could be wrong but as far as I've experienced this value you can not be set in the htaccess since its not supported, not every php.ini change can be done via the htaccess for security reasons.

open_basedir should be set in the httpd.conf, php.ini or vhost.conf

Most web hosting providers actually allow you to create your own php.ini in the home folder of your account, in fact I've yet to come across one that doesn't allow this. Basically yes you use a shared php.ini but you can create your own with certain values in your hosting folder, this is not something which they advertise and you need to ask.

Personally I'd get back on to your support at the hosting, after all isn't that what your paying for?

  • 2
    @sam - Additionally, it would not be in a host's best interest to allow people to override this, since it could be used to run PHP shells on their servers, and jeopardize the security of others' websites. As far as I know, I don't believe you can change/override this setting using .htaccess files. This would defeat the entire purpose of the setting.
    – ionFish
    Mar 28, 2013 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.