Q:

redirecting url from one subfolder to another using conf file / ubuntu

I have web site on domain.com
which is located at /var/www/main
I also have started another web site which I want to be on url domain.com/a/b
But the actual file location is /var/www/main/a/b/c
Problem is that I want the users to use url domain.com/a/b and get files from /var/www/main/a/b/c
So I've found domains conf file at /etc/apache2/sites-available/domain.com.conf
It had only this
<virtualhost *:80>
    ServerName domain.com
    DocumentRoot /var/www/main
</virtualhost>

Now after reading different topics about it I've tried to add this so now my domain.com.conf file looks like this
<virtualhost *:80>
    ServerName domain.com
    DocumentRoot /var/www/main
</virtualhost>

<virtualhost *:80>
    ServerName domain.com
    ServerPath /a/b/
    DocumentRoot /var/www/main/a/b/c
    RewriteEngine On
    RewriteRule ^(/a/b/.*) /var/www/main/a/b/c
    # ...
</virtualhost>

But this does not work at all.
What am I doing wrong ?

A:

No need for Rewrite Rules. Just set up an alias in /etc/apache2/sites-available/domain.com.conf :
<virtualhost *:80>
    ServerName domain.com
    DocumentRoot /var/www/main
    Alias /a/b /var/www/main/a/b/c
</virtualhost>

Then restart apache :
$ sudo service apache2 restart

