2

Does anyone know the solution to this problem?

I checked my zone file and there are 2 A records

mydomainname.com.   14400   IN      A       ip.address.x.x

localhost       14400   IN      A       127.0.0.1

CNAME entries currently in my zone file

mail    14400   IN      CNAME   mydomainname.com.
www     14400   IN      CNAME   mydomainname.com.
ftp     14400   IN      CNAME   mydomainname.com.

I'm On CentOs 5.2, by the way.

Thanks for the help!!

  • @kbyrd: I don't understand your nit. How is that different from what he wrote? Are you confused about the trailing period? It's supposed to be there, however some DNS servers will automatically add it for you if you forget it. But it's good to put it there just in case. – davr Mar 29 '10 at 17:19
  • @jeff: Please tell us the actual problem. "doesn't work" doesn't tell us enough information. Does the hostname resolve to an IP address? Does it connect to the server? etc etc. – davr Mar 29 '10 at 17:20
  • @davr: domain doesn't resolve without the www. –  Mar 29 '10 at 23:22

3 Answers3

3

This is most likely a web server configuration problem. You can confirm or deny this by ping/dig/nslookup the domain name both with and without the 'www.'. If pinging (for example) each hostname resolves to the same IP address, your DNS is working properly.

For Apache, the configuration in /etc/httpd/conf/httpd.conf should look something like:

<VirtualHost *:80>
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com
    ServerAdmin webmaster@yourdomain.com
    DocumentRoot /home/sites/yourdomain.com/web
    ErrorLog /home/sites/yourdomain.com/logs/error_log
    TransferLog /home/sites/yourdomain.com/logs/access_log
</VirtualHost>

Optionally, if you want to use mod_rewrite to enforce the 'www' component, add the following before the ending </VirtualHost> tag:

RewriteEngine on
RewriteCond %{HTTP_HOST}            !^www.yourdomain.com(:80)?$
RewriteRule ^/(.*)                  http://www.yourdomain.com/$1 [L,R]
RewriteOptions inherit
Joe
  • 1,765
  • 15
  • 23
  • Thanks for you help! I'm afraid, though, that my httpd.conf file looks just like your example for ServerName and ServerAlias so perhaps that not it. To confirm, pinging without www doesn't resolve. Would restarting something other than apache help? Thanks again for your time! –  Mar 29 '10 at 23:17
2

Either add an A record for www to point to your ip address, or add a CNAME for www to point to the root (each has it's own set of positives/negatives for large organizations, but either would make your www go).

Brian Knoblauch
  • 2,188
  • 2
  • 32
  • 45
  • Sorry, but i'm a novice at server configuation. How would this look like? Something like this?: www.mydomain.com 14400 IN A ip ? Also, is the amount of spacing significant? –  Mar 29 '10 at 16:42
  • I added my current CNAME entries in my original post for clarity. Thanks for the help! –  Mar 29 '10 at 16:47
1

Check your webserver configuration and ensure it is accepting connections to both domain.com and www.domain.com. In Apache this would be the ServerAlias line.

TerryS
  • 136
  • 1