如何拒绝从php读取top目录



我刚刚在服务器上添加了新的VirtualHost。(在config..下面(如何禁止浏览top目录(例如:opendir('../../public_html/aother_site/'(?我应该向配置中添加什么?我想要独立的网站目录。也许这是错误的方式?php/apache-config?

<VirtualHost *:80>
ServerName mysite.pl
ServerAlias www.mysite
DocumentRoot /var/www/public_html/mysite
<Directory /var/www/public_html/mysite>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm index.php5
</IfModule>
</VirtualHost>

我刚刚找到了一个好的解决方案。根据网站";https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=115522526"我添加了php_admin_value open_basedir/srv/web/domain.tld/:/usr/share/pear/

<VirtualHost *:80>
ServerAdmin admin@domain.tld

DocumentRoot /srv/web/domain.tld/htdocs
ServerName domain.tld
php_admin_value open_basedir /srv/web/domain.tld/:/usr/share/pear/
php_admin_value upload_tmp_dir /srv/web/domain.tld/
php_admin_value session.safe_path /srv/web/domain.tld/sessions/

<Directory /srv/web/domain.tld/htdocs>
php_admin_flag engine on
AllowOverride AuthConfig FileInfo
Order allow,deny
allow from all
</Directory>
</VirtualHost>

最新更新