by Robert Brenstein.
In standard Moodle installation, you can use only one domain, that is either with or without www. While DNS is kind enough to match them onto each other, they are two different domains to Moodle and your Moodle config knows only one of them. It seems to be the one with www since it displays correctly from start on. The reason it works again when you continue deeper after connecting with shorter domain is that the domain from config takes over. If you really need to use both versions of your domain, you need to do some magic with your config file to support two domains with the same Moodle instance. Search moodle.org for instructions.