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
</VirtualHost>
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 ofServerAlias 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 theServerName
You will need to make sure that you have valid DNS A record set for
server.com.au
and either an A or CNAME forwww.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.and you can also create a WildCard 'A' record it will make anything.server.com.au work.