I have made simple http server on Ubuntu 14.04 with LAMP and put my html, php and js files to apache root directory /var/www/. All paths within these files are absolute and looks like /script1.php or /subdir/script.php. Directory tree of web server looks like:
/
|---var
    |---www
        |---script1.php
        |---subdir
|---usr
|---home
|---etc 
File /etc/apache2/sites-available/000-default.conf:
   ServerAdmin webmaster@localhost
   DocumentRoot /var/www
    <Directory />
            Options Indexes FollowSymLinks
            AllowOverride All
            Order Allow,Deny
            Allow from all
    </Directory>
    Alias /data /var/www/
    <Location /data>
            DAV On
            AuthType Digest
            AuthName "webdav"
            AuthUserFile /usr/local/apache2/.digest_passwd.dav
            Require valid-user
            Order Allow,Deny
            Allow from all
            DirectoryIndex disabled
    </Location>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
The problem is in the point that all paths begin from root server directory.
for example, php command opendir('/') shows list:
/
|---var
|---usr
|---home
|---etc 
but I need list like that
/
|---subdir
|---script1.php
So, how can I make Apache think that '/' means not root web server directory, but root apache directory?
                        
opendir takes an actual path not the path of the web server's document root. Thus, opendir("/") is working correctly to show you the server's root directory.
As mentioned by Vladimir, rather use
or probably better for security