Fix that Web Site!
I can’t recall how many times I’ve entered a domain name in a browser, say ‘domain.com’, only to wait 30 seconds and get an ugly 502 Bad gateway error in return. The problem? Enter http://domain.com instead of http://www.domain.com and see what happens.
- you are served the expected website, the url stays the same
- you are redirected to http://www.domain.com or some other url
- you get a 502, Bad gateway timeout
I don’t know if it’s laziness, lack of knowledge or simply host providers being plain rubbish, but it’s an annoying problem that can be solved extremely simply!
Most of websites that are not configured properly often get away with it as many internet users believe that ‘www’ is a compulsory part of any web URL.
In fact it’s only because of an old practice of naming hosts according to the services they provide, in our case a web site, with www. FTP using ftp.domain.come etc. But it has nothing to do with any technical issue or any standard. Not many (if any) ‘Mr average’ know this!
One of the problems is that with the advent of new web browsers that suggest you URLs from your history, or even perform straight away an interactive search of web resources that match your typing, it is very easy to fall into the usual consumer laziness and let the browser find everything for you. That way, you get into the habit of accessing a website just by typing the domain name, without www or any other prefix, and sometimes even without the top level domain (The ‘.com’ or other ‘.something’).
I’m the first to do it and that’s why I probably end up on these poorly configured web servers from time to time. But I am still quite astonished to it see happen, as it can seriously lead to some misunderstanding from the average user. If I don’t know anything of internet, don’t care about ‘www’s, just type a domain name in my browser and get an error page, I’m not going to try very long to search for how to access that site!
That problem has a simple solution though.
First, if you have access to them, check your DNS records. This step might not be compulsory, but it won’t harm to check them anyways. Your domain will have an A record to point your domain name to the IP of the host of your web site:
domain.com A 0.0.0.0
You can also add either an A or a CNAME record for the www sub-domain. The syntax differs:
domain.com A 0.0.0.0 www.domain.com A 0.0.0.0 www.domain.com CNAME domain.com.
Second, check your web server configuration that it actually is accepting requests from sub-domains and serving the proper files. In Apache, for example, you can set it up by adding a virtual host:
Listen 80 NameVirtualHost * <VirtualHost *> ServerName www.domain.com DocumentRoot /home/httpd/htdocs/ </VirtualHost> <VirtualHost *> ServerName domain.com DocumentRoot /home/httpd/htdocs/ </VirtualHost>
or using a server alias:
Listen 80 NameVirtualHost * <VirtualHost *> ServerName domain.com ServerAlias www.domain.com DocumentRoot /home/httpd/htdocs/ </VirtualHost>
So yes, I admit, you have to have access to the DNS entries and the configuration files of the server. But even if you don’t and it’s down to the host provider to configure the DNS and the web server files, it is very easy to set these up properly.
Ok, again, you might argue that you could serve a different version of the site with http://domain.com and http://www.domain.com, but if you don’t and there is no redirection in place, just make sure you don’t serve a 502.