In some situation you may need to redirect your website to another website.
For example I have two domains example.net and example.com. Since I don't have any web pages uploaded for example.net, I just want to redirect example.net to my existing site example.com.
Create an Apache virtual host for example.net and redirect your website using mod_rewrite.
You can look apache site for more details about mod_rewrite module. Apache Rewrite Module
Here is my virtualhost configuration for example.net
DocumentRoot /var/www/example.net
ServerName example.net
ServerAlias www.example.net
ServerName example.net
ServerAlias www.example.net
Options +FollowSymLinks
RewriteEngine on
Redirect 301 / http://example.com/
RewriteCond %{HTTP_HOST} ^([^.:]+\.)*example\.net\.?(:[0-9]*)?$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
</Directory>
</VirtualHost>
No comments:
Post a Comment