3

I want to enable the access to my site without the "www." prefix. I tried to insert this in my /etc/apache2/sites-available file:

<VirtualHost *:80>
        serverName mydomain.gov.br
        serverAlias www.mydomain.gov.br
        ServerAdmin webmaster@mydomain.gov.br

        DocumentRoot /var/www/mydomain/

        ... (lot's of other configs)
</VirtualHost>

But this isn't working... :(

When I dig the domains I get different IP results:

www.mydomain.gov.br - 201.143.203.67

mydomain.gov.br - 201.143.203.65

splattne
  • 28,348
  • 19
  • 97
  • 147
Thiago Belem
  • 135
  • 1
  • 3
  • 12

5 Answers5

14

serverAlias needs to be title caps (ServerAlias) and you need to add whatever sites you want this virtual host to respond to on this line, separated by a space like so:

ServerAlias www.mydomain.gov.br mydomain.gov.br something.mydomain.gov.br

Make sure that you have a A host record for mydomain.gov.br (or a CNAME) so that it can be resolved properly. Also I'm not sure if you've ran a2ensite yet, you didn't say whether it was working at all or not.

EDIT Apparently you need step-by-step instructions on how to change your DNS records. However, unless you're going to post your actual domain (and we can look up your NS records), we have no idea who controls your DNS or how to change them.

To figure this out without posting your actual domain, you can do:

dig ns mydomain.gov.br

This should return some records like ns1.somecompany.com ns2.somecompany.com, etc.

Does "somecompany.com" ring a bell? If not, who registered this domain? Can you contact them? They likely have access to the nameservers or know someone who has access to the nameservers. You can also look up the WHOIS records and you may see an email address there that's familiar to you.

gravyface
  • 13,947
  • 16
  • 65
  • 100
  • And how do I create this `A record` or `CNAME`? – Thiago Belem Apr 12 '10 at 17:32
  • 1
    Through your registrar or DNS provider/server where you setup mydomain.gov.br in the first place. – gravyface Apr 12 '10 at 17:37
  • @gravyface - This is not made locally (I mean, in the server.. it's a dedicated server)? – Thiago Belem Apr 12 '10 at 17:39
  • All I'm saying is that if your dedicated server has the following IP address (11.22.33.44), you need to make sure that mydomain.gov.br resolves to that IP address on whatever machine you're trying to access your website. – gravyface Apr 12 '10 at 17:44
  • 1
    The `A` record and `CNAME` refer to DNS entries for the given domain (`mydomain.gov.br` in your question). How to create them depends upon which DNS server the site is using (e.g. named/bind, PowerDNS, djbdns, dbndns). – mctylr Apr 12 '10 at 17:45
  • So both `host mydomain.gov.br` and `host www.mydomain.gov.br` should return the IP address of the server, if DNS is correctly configured. – mctylr Apr 12 '10 at 17:49
  • @mctylr I checked the resolved IP of both domains and they're goin to differents IPs... This can be a badly router configuration (on the server, ofc)? – Thiago Belem Apr 12 '10 at 21:06
  • 1
    No, this would be wrong in your nameservers. – gravyface Apr 12 '10 at 21:40
5

This is definitely a DNS problem; you should of course configure your web server as appropriate for your needs, but if "mydomain.gov.br" doesn't point to it, you're not going anywhere :-)

Massimo
  • 68,714
  • 56
  • 196
  • 319
1

Your Apache config looks ok to me. The DNS record for mydomain.gov.br should point at the same IP address as the www. one, unless Apache is also listening on this IP address - but if it were then your site would probably work.

You need to check your DNS service to figure out where the record for the www. free record is being defined.

dunxd
  • 9,482
  • 21
  • 80
  • 117
0

if your problem seems to be with name resolution, then I would agree you would a CNAME record for the domain as an alias. Your domain may already have a corresponding A record for it, this may be why the domain has been mapped to a different IP. Add the same A record for it as the alias, or map a CNAME string to it, A record incurs less overhead, b/c of no CNAME chain

s1los
  • 48
  • 3
-2

My guess is that you dont need the "ServerAlias www.mydomain.gov.br" string at all. You only need the "ServerAlias mydomain.gov.br"

Then, in you DNS servers domain management screen (which I presume you have) you need to set up the DNS pointer records correctly.

djangofan
  • 4,172
  • 10
  • 45
  • 59