<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example1.com
ServerAlias example2.com
<Directory /var/www/example1>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
DocumentRoot /var/www/example1
RewriteEngine On
RewriteCond %{HTTP_HOST} example2\.com [NC]
RewriteRule (.*) /example2$1 [L]
</VirtualHost>
ServerAdmin webmaster@localhost
ServerName example1.com
ServerAlias example2.com
<Directory /var/www/example1>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
DocumentRoot /var/www/example1
RewriteEngine On
RewriteCond %{HTTP_HOST} example2\.com [NC]
RewriteRule (.*) /example2$1 [L]
</VirtualHost>
Or remove highlighted code from above VirtualHost and add the below code to .htaccess of example1's root directory.
RewriteEngine On
RewriteCond %{HTTP_HOST} example2\.com [NC]
RewriteRule (.*) /example2$1 [L]
RewriteCond %{HTTP_HOST} example2\.com [NC]
RewriteRule (.*) /example2$1 [L]
Post a Comment