Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache: How to serve a path from a different directory without symlinking?

Tags:

apache

I have a one project being hosted in Apache under a specific subdomain:

<VirtualHost *:80>
    ServerName dev.example.com
    DocumentRoot /web/vhosts/dev.example.com
    <Directory />
        Allow from all
    </Directory>
</VirtualHost>

I want to serve another project under a subdirectory of this domain:

dev.example.com/special-project

Which lives in /web/vhosts/special-project. I also can't simply create a symlink to this directory because of the way the original project is structured. It has to be configured using Apache only.

How do I configure Apache to be able to do this? Also, can this type of configuration be specified in a separate file, or does it have to be part of the original VirtualHost definition?

like image 447
Andrew Avatar asked Apr 23 '12 21:04

Andrew


People also ask

Can we serve content out of a directory other than the document root directory?

This config will show a basic example on how to server a content out of directory other that the DocumentRoot directory using Apache2 web server. Let's begin with a simple virtual host configuration. The given html document has been loaded from the DocumentRoot directory /var/www/html .

What is DocumentRoot in Apache?

The document root is a directory (a folder) that is stored on your host's servers and that is designated for holding web pages.


1 Answers

Use an Alias.

Alias /special-project/ /web/vhosts/special-project/
like image 178
unbeli Avatar answered Sep 23 '22 02:09

unbeli