0

I want to limit access to files using PHP open_basedir for multiple domains. Every domain sits in own directory, so I want prevent all domains PHP scripts from interfering with each other. How can I set different open_basedir path for every domain in single .htaccess?

If it would be only 1 domain, it could look like this:

# /hosting/domains/.htaccess
php_value open_basedir /hosting/domains/example.com/

Every user has FTP account limited to /hosting/domains/example.com/. So, obviously, I can not put .htaccess into /hosting/domains/example.com/.htaccess as user would be able to change .htaccess content. So, there must be single .htaccess in /hosting/domains/.htaccess for all domains.

This is how I imagine it, is something like this possible?

# /hosting/domains/.htaccess
php_value open_basedir /hosting/domains/${current_domain}/

I am using: Apache 2.4, PHP 5.5

Martin
  • 109
  • 2
  • 5

2 Answers2

1

You can set open_basedir into virtualhost, so users won't be able to edit or delete it, within <Directory> directive.

mapolone
  • 11
  • 5
0

I think it is not possible. Every domain has to have specific .htaccess file because this file is settings per folder so there is no way to specify subfolder. And even this is possible then user can use his own .htaccess file to override settings.

On shared hosting is only one solution. One user account per domain.

Tomáš
  • 109
  • 3