Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are using Bind9 on our DNS servers. We have all of our zone files structured with the following format in our /var/named/slaves directory: 

Each .hosts file contains the following information:

$TTL 3600       ; 1 hour             IN SOA (
                                2012042601 ; serial
                                3600       ; refresh (1 hour)
                                600        ; retry (10 minutes)
                                86400      ; expire (1 day)
                                3600       ; minimum (1 hour)
www                     A 

Our named.conf file has the following info:

options {
        directory "/etc";
        pid-file "/var/run/named/";
        recursion no;
        notify yes;
        listen-on { 10.xx.xx.xx;; };
        allow-transfer { 10.xx.xx.xx; };
        version "[bitch-got-denied]";

zone "." { type hint; file "/etc/db.cache"; };

zone "" { type master; file "/var/named/slaves/"; allow-update { none; }; }; zone "" { type master; file "/var/named/slaves/"; allow-update { none; };

Lets say I have both & .hosts files pointing to the same IP. If someone goes to or it resolves to the same server, the only obvious difference is the name in the URL bar (depending on which FQDN the client uses to navigate to our domain.)

My question and what I need help with is, I want when someone goes to that in the URL bar it gets redirected to I know I can use my hosting company to just do a redirect (standard or stealth) through their online interface, but wanted to see if this could be done on our DNS servers. I simply want a standard redirect. Perhaps I need to mess with the Webserver itself... Any feedback on the best way to accomplish this would be greatly appreciated!

share|improve this question
up vote 5 down vote accepted

No - an HTTP redirect (the kind that changes the address bar) can never be done in DNS alone; DNS providers who offer this kind of service simply point the name to their own HTTP server and configure the redirect there.

You will need to configure this on your web server - let us know what kind of server it is and we can help you through configuring the redirect.

Edit: To configure your Apache to redirect:

  • Add a new site file: /etc/apache2/sites-available/redirect
  • Give that file these contents:

    <VirtualHost *:80>
        Redirect permanent /
  • Enable the site: a2ensite redirect

  • Activate the new config by gracefully restarting the Apache service: service apache2 reload
share|improve this answer
Thanks for the info Shane! Server version: Apache/2.2.20 (Ubuntu) – Blake Jun 14 '12 at 17:17
@Blake Ok! Is the configuration mostly standard, with configuration for your main site in /etc/apache2/sites-available/default? – Shane Madden Jun 14 '12 at 17:28
Yes. The configuration is standard. – Blake Jun 14 '12 at 18:14
@Blake I've edited my answer with a basic redirection config. Let me know if that doesn't work for you. – Shane Madden Jun 14 '12 at 18:27
This is exactly what I needed. Everything works flawlessly, thank you for the guidance Shane! I really appreciate your time – Blake Jun 14 '12 at 18:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.