Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache multiple DocumentRoot

People also ask

What is DocumentRoot in Apache server?

The DocumentRoot is the top-level directory in the document tree visible from the web and this directive sets the directory in the configuration from which Apache2 or HTTPD looks for and serves web files from the requested URL to the document root. For example: DocumentRoot "/var/www/html"

Where is DocumentRoot in Apache2?

On a fresh installation of Apache, the document root is located at /var/www/html . By following the prerequisite guides, however, you created a new document root, /var/www/ example.com /html .

What is the DocumentRoot in webserver?

The web server document root is the root directory of the web server running on your system. The documents under this root are accessible to any system connected to the web server (provided the user has permissions). If a file is not under this root directory, then it cannot be accessed through the web server.

What is the default location of DocumentRoot?

On Ubuntu, by default, the Apache2 web server stores its documents in /var/www/html , which is typically located on the root filesystem with rest of the operating system. Sometimes, though, it's helpful to move the document root to another location, such as a separate mounted filesystem.


Use Alias:

Alias /ABC/ /var/www/ABC/
Alias /PQR/ /var/www/PQR/

Leave the document root pointing to /var/www/Others/index.php. It could do the trick. :)


You can do this with mod_alias, which is part of the apache distribution.

http://httpd.apache.org/docs/current/mod/mod_alias.html

for serving everything else with the single file you would use mod_rewrite. This has many features and depending on your needs you might need to tweak that.. but something like this should work:

RewriteEngine on
RewriteRule ^(.*)$ /index.php?path=$1 [L]

you would put that in a .htaccess file in the document root.