Thursday, February 3, 2011

url without www doesn't work but set up properly!?

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

  • 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

    Radek : @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
    ErikA : @Radek, do you have a DNS A or CNAME record for www.server.com.au?
    Radek : @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.
    ErikA : @Radek - oh, then do you have a valid DNS A or CNAME for server.com.au?
    Radek : @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 : can I solve that without creating/updating these records?
    ErikA : @Radek - see my answer below.
    From Prix
  • 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.

    Daniel Lawson : 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).
    Radek : @Daniel Lawson: so, what's the solution? :-)
    ErikA : Clarified my answer.
    From ErikA
  • 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.

    Radek : @Daniel Lawson: could you point it out how I can add A record for server.com.au?
    Daniel Lawson : @Radek: That will depend entirely on who is hosting your DNS infrastructure. If you run the DNS on your own server, it's just a case of adding that record in your DNS server configuration. If someone else runs it, and they have a web management system, it should let you do it there. If they don't have a web management system, ask them directly for how to add the record.
    Radek : cool, thank you.
  •    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.

    From CDNPIC

0 comments:

Post a Comment