Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a domain for my site:

example.com

I am also running local DNS with these lines:

www IN CNAME server.<host_provider>.com.
dev IN CNAME server.<host_provider>.com.

So www.example.com and dev.example.com go to production and development sites, respectively, that are hosted by a host company.

In my Apache configuration for the main site, I'm running a rewrite rule like this:

RewriteEngine ON
RewriteCond %{HTTP_HOST} ^example\.com$|!dev\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www\.%{HTTP_HOST}/$1 [R=302,L,NE]

This rule seems to work, as when you are off the network and go to example.com in the browser, you get redirected to www.example.com.

The problem is when I'm on the network, and I go to example.com I get an error page, saying page can't be found. No server errors; just a page can't be found, as if the local DNS is causing it to stop looking at that point.

I'm also using Nettica for DNS service and have this A record in place:

example.com Host (A) Default xxx.xx.xxx.xx

This handles the external DNS, but my problem seems to be related to my internal DNS.

For example, inside my network, I can go to servers on the network with addresses like this:

server.example.com server1.example.com server2.example.com

These are configured in my local DNS. I'm just not sure how to get past the "empty" subdomain and go to example.com.

Adding to this since it might not be clear. If I'm out side the example.com network, on another network, like example123.com, then when I go to example.com I'm redirected to www.example.com as expected, eg, the Apache rewrite rule is working.

EDIT

With the help of @ErikE and troubleshootinig and testing, I found an answer. Seems I discovered another way along with @ErikE's suggestion:

In local DNS adding either one of these seems to work:

example.com IN CNAME server.<host_provider>.com.
example.com IN CNAME www.example.com.

Thanks.

share|improve this question
1  
I wish I could actually get information about why there is a down-vote. Is this really that bad of a question? –  nicorellius Nov 5 '13 at 20:58
    
don't worry about votes buddy... they worth less than reddit votes –  Howard Nov 5 '13 at 21:10
    
I know, dude, but the whole point is constructive criticism and advice. Faceless down-votes are just lame... Especially when it's a genuine question that has a good amount of details. –  nicorellius Nov 5 '13 at 21:22
    
Well, if you are in the example.com network does the example.com record resolve to what you expect it? Is there a DNS setup at that site which has this zone also configured (Active Directory maybe)? –  faker Nov 5 '13 at 21:28
1  
When you're inside the network and you use dig or nslookup, whats the returned result when you query for example.com. Is it what you expected? And if the Server is in the same network as you, is it possible this is a firewall issue where you're trying to go out the network and then right back in? –  Safado Nov 5 '13 at 21:43

1 Answer 1

up vote 1 down vote accepted

It sounds to me like you need an empty A record (or other record to the same effect) for the domain example.com itself in your local dns.

If I remember correctly (some time has passed since I last did this), in BIND this can be achieved using the following syntax in the zone file of example.com:

A    1.2.3.4

or in Windows DNS:

@    IN A    1.2.3.4

However, using dnsmasq for instance this would be configured in a completely different way. So, what brand of dns server are you using locally?

I am uncertain if one can write CNAME records in the same way. You could certainly try if you wish to refer to your provider instead of writing the ip addresses explicitly in your local dns.

share|improve this answer
1  
Nice answer... It made me think of another solution. See my OP. Awesome ;-) –  nicorellius Nov 5 '13 at 22:53

Your Answer

 
discard

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.