[solved] domain doesn't work without www
I have a domain that is working ok, but if I remove the www, it shows the page "It Works!". I can't make it point to the same location as with www.
I have the following configuration in /etc/apache2/sites-available/postalote.com:
<virtualhost *:80="">ServerAdmin mail@postalote.com
ServerName postalote.com
ServerAlias www.postalote.com
DocumentRoot /srv/www/postalote.com/public_html/
ErrorLog /srv/www/postalote.com/logs/error.log
CustomLog /srv/www/postalote.com/logs/access.log combined</virtualhost>
and in /etc/hosts:
127.0.0.1 localhost.localdomain localhost
109.74.196.124 postalote.com postalote
109.74.196.124 otherdomain.com otherdomain
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
The strange thing is that I have another domain with the same configuration (but pointing to another location) and it works ok, with and without www.
Thank you!
3 Replies
Your DNS is correct, they both resolve to your IP.
#nslookup postalote.com
Name: postalote.com
Address: 109.74.196.124
#nslookup www.postalote.com
Name: www.postalote.com
Address: 109.74.196.124
I am not too familiar with what the /etc/hosts file is used for. But I looked in mine and the domain was not in there by itself.
Mine looks like this, with the xx masking my real IP, and example.com taking the place of my real primary domain.
127.0.0.1 localhost
xx.xx.xxx.xx leroy.example.com leroy
So it has hostname.domain and then hostname, but not just domain. Since your domain name by itself is being the culprit and it is in your hosts file, to me it might be the problem.
So maybe give that a try. Also it is along the lines of "is your computer plugged in" but did you reload or restart Apache after your configuration change. It has happened to me on more then one occasion.
I am really just guessing here, just helping you troubleshoot so please make backups and don't get mad if my suggestions screw things up.
Thanks kali25!