Local DNS and Apache Server Configuration Interferring - example.com / www.example.com

Posted by nicorellius on Server Fault See other posts from Server Fault or by nicorellius
Published on 2013-11-05T20:43:44Z Indexed on 2013/11/05 21:55 UTC
Read the original article Hit count: 365

Filed under:
|
|

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.

Thanks in advance for any information.

© Server Fault or respective owner

Related posts about apache2

Related posts about dns