Apache redirect domain to another domain

Questions related to the Apache server
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

Apache redirect domain to another domain

Post by mister_v »

Hi,

I want to redirect domain.net to domain.com.
How can I best do this with Apache.

I know ho to do it with javascript, but then I have to do it on every page.

Code: Select all

 <meta http-equiv="Refresh" content="3; URL=http://www.domain.com/index.php"/>
I don't want that.
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: Apache redirect domain to another domain

Post by chris »

I think what you are looking for is ServerAlias redirect.

In you virtualhost config files you can put the following:

Code: Select all

<VirtualHost *:80> 
    ServerAlias yoursite.net
    redirect permanent / http://yoursite.com/
</VirtualHost> 
It will respond with a permanent redirect status (301),
and redirect all request to the new domain.
with directory and file-name.
Post Reply