Page 1 of 1

Apache redirect domain to another domain

Posted: Sun Aug 07, 2011 8:02 pm
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.

Re: Apache redirect domain to another domain

Posted: Sun Aug 07, 2011 9:33 pm
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.