typing www.server.com.au in a web browser works fine I want to be able to access the web by entering server.com.au too

  • A name record exists only for www.server.com.au
  • CNAME for both and A name for server.com.au don't exist

my /etc/apache2/listen.conf contains lines

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName server.com.au
    ServerAlias server.com.au 
    DocumentRoot /srv/www/htdocs/www.server.com.au/www

and list of virtual servers gives me

[root][saas1 /srv/www/htdocs/www.server.com.au/www] httpd2 -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
     default server server.com.au (/etc/apache2/listen.conf:47)
     port 80 namevhost server.com.au (/etc/apache2/listen.conf:47)

but http://server.com.au is not accessible

I restart the server by httpd2 -k restart


If you want both "server.com.au" and "www.server.com.au" to work,, then both of those hosts need to have DNS records setup.

You can either:

  • give both of them an A record, pointing at the same IP address

  • give server.com.au an A record, pointing at the IP address of your server, and give www.server.com.au a CNAME, pointing at server.com.au.

I suspect the first approach is easier, because you already have an A record setup for www.server.com.au.

As I suggested in a comment, you really don't want to use a CNAME on the "server.com.au" record. This violates the spec, and while it may look like it works, can do unpredictable things. Far better to just stay away from putting a CNAME on "server.com.au" entirely.

Once you've got that working, you'll need to make sure apache knows about both names - which has already been covered by the discussion around ServerAlias and ServerName directives.


It should be ServerAlias www.server.com.au instead of ServerAlias server.com.au was that a typo ?

If you do not want the www then just delete ServerAlias server.com.au all you gona need is the ServerName

  • @prix I tried both ServerAlias www.server.com.au and ServerAlias server.com.au and none worked. I want the site to be accessible using both www and without www
    – Radek
    Aug 24 '10 at 1:10
  • @Radek, do you have a DNS A or CNAME record for www.server.com.au?
    – EEAA
    Aug 24 '10 at 1:17
  • @ErikA: I have no idea.How can I find out?Note that www.server.com.au works fine. It's server.com.au that is not accessible.
    – Radek
    Aug 24 '10 at 1:19
  • @Radek - oh, then do you have a valid DNS A or CNAME for server.com.au?
    – EEAA
    Aug 24 '10 at 1:21
  • @ErikA: A name record exists only for www.server.com.au CNAME for both and A name for server.com.au don't exist
    – Radek
    Aug 24 '10 at 1:28
   ServerName www.server.com.au
   ServerAlias   server.com.au
   ServerAlias *.server.com.au

and you can also create a WildCard 'A' record it will make anything.server.com.au work.


You will need to make sure that you have valid DNS A record set for server.com.au and either an A or CNAME for www.server.com.au, depending on your needs. This is the only way that your customers' browsers will be able to know which server to contact to access your website.

  • You do NOT want a CNAME for server.com.au, this will stop a lot of things working. You cannot have a CNAME and other records (such as A, MX, and most importantly, NS records). Aug 24 '10 at 3:06
  • @Daniel Lawson: so, what's the solution? :-)
    – Radek
    Aug 24 '10 at 3:17
  • Clarified my answer.
    – EEAA
    Aug 24 '10 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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