Apache2: redirect different domains to subfolder

In the aim to merge two of my server on digitalocean, today I tried to write a mod_rewrite rule to redirect a secondary domain to a subfolder. After one hour, I found that I can do that with a VirtualHosts!

Just edit the file /etc/apache2/sites-available/default and add a rule for each domain at the end of file:

<VirtualHost *:80>
ServerName http://www.domain.org
DocumentRoot /var/www/vhosts/domain.org/www

It’s easy, if you know.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: