Mapping different ServerPath to different DocumentRoot with the same address

5,209

You could try using mod_alias and the Alias directive

<VirtualHost *:80>
  ServerName servername
  DocumentRoot /dummy/path
  Alias /path1 /path/to/mounted/fs/path1
  Alias /path2 /path/to/other/fs/path2
</VirtualHost>

See http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias for details.

Share:
5,209

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I am using an Apache server within an intranet to give access to reports. I want, with the same servername, to map a server path to a different documentroot that happens to be a file share.

    Is this feasible with a VirtualHost ?

    <VirtualHost *:80>
        ServerPath /path1
        DocumentRoot remote-share
        ServerName servername
    </VirtualHost>
    
    <VirtualHost *:80>
        ServerPath /path2
        DocumentRoot remote-share
        ServerName servername
    </VirtualHost> 
    
    <Directory /path1>
        Options Indexes
    </Directory>
    
    <Directory /path2>
        Options Indexes
    </Directory>
    

    In this case, path1 works but overrides path2 therefore path2 never works - probably because it's the same virtual host - but again, I need to have the same address, just different sub-folders mapped to different DocumentRoots.