Point all Domains to one server (in Apache)

Let’s say the marketing department can’t make up its mind on which domain name to use. It’s between ultimatefoo.com or uberfoo.com.

So you build a website and point both domains to the same server. Easy.

Then one day, they say, hey, let’s go with uberfoo.com cuz it’s shorter and “uber” is the buzz word for the moment. Now they want you to redirect customers who go to ultimatefoo.com to uberfoo.com just so it’s consistent.

On the domain management side, you can just forward all request to ultimatefoo.com to uberfoo.com.
In GoDaddy, you select your domain and go to the Settings tab to find the Forwarding section
Screen Shot 2015-06-05 at 4.32.54 PM


Then Click Add Forwarding

Screen Shot 2015-06-05 at 4.32.42 PM

Fill in the Forward To section:

Screen Shot 2015-06-05 at 4.32.06 PM


Simple enough… if you have IT access to the domain. But what if you didn’t?

Suppose you wanted to do it strictly from Apache. Here’s how.

Open the .conf file. Its location is machine-dependent. I found mine at /etc/apache2/sites-available/25-http.conf

Now you’ll need to modify it to create two <VirtualHost> sections. One should already be there.

For the existing one, modify the ServerName if you haven’t done so already to uberfoo.com:

<VirtualHost *:80>
  ServerName uberfoo.com
  DocumentRoot "/var/www"

Next create a second VirtualHost that redirects to it like so

<VirtualHost *:80>
  ServerName ultimatefoo.com
  Redirect "/" "http://uberfoo.com"

Now you don’t even have to bother the IT guy in charge of domains 🙂

Tagged ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: