domain forwarding with Apache mod_rewrite

You might have the domain domain1.com which should redirect visitors to domain2.com. You could set up a virtual host, pointing to /path where an index.php file resides which forwards the user, e.g. with:

The easier way is to create a virtual host, e.g. by creating /etc/apache2/sites-available/domainForwarding with the following content:

This makes mod_rewrite (which must be enabled) to forward the request whithout the need for additional files.

Note: run a2ensite domainForwarding to enable the site and /etc/init.d/apache2 reload to update the apache’s configuration.

Leave a Reply

Your email address will not be published. Required fields are marked *