Web Hosting Talk







View Full Version : Redirecting (in Apache) all domains to one domain


Wine
07-04-2003, 02:46 PM
I've been playing with Apache's redirection directives for a while, trying to have all my domains redirected to bar.net when someone tries e.g. www.bar.net, foobar.net and so on, showing http://bar.net/ in the address line of the browser.

This regardless of the URL someone tries to access; if someone tries http://www.foo.net/cake/monster.html, I want them redirected to http://bar.net/cake/monster.html.

I haven't figured out how yet, but I assume someone here knows how.

Thanks a lot!

sour
07-04-2003, 03:08 PM
You would have to make something kind of like this in httpd.conf (/usr/local/apache/conf/httpd.conf):

<VirtualHost (ip address)>
ServerAlias www.bar.net bar.net
ServerAdmin email@domain.net
DocumentRoot /home/<username>/public_html
BytesLog domlogs/bar.net-bytes_log
User <username>
Group <username>
ServerName bar.net
ServerAlias www.foo.net foo.net
User <same user as bar.net>
Group <same user as bar.net>
CustomLog domlogs/bar.net combined
ScriptAlias /cgi-bin/ /home/<same user as bar.net>/public_html/cgi-bin/
</VirtualHost>

That should make foo.net mirror what is on bar.net.
Hope this helps. You can add many more just by defining new ones like i did with foo.net just make sure you end it with </virtualhost> and that you backup httpd.conf before you do any of this. :)

example:
http://www.fissionhost.com
http://www.fissionhosting.com

(same setup as i posted above)

choon
07-04-2003, 04:34 PM
And make sure that all your domain pointed to the same ip address as in your DNS which should be the same as in your VirtualHost IP :)