Why some sites require the www prefix while others work just fine without it
Ever wondered why some web sites work if you type their name without the www. prefix, while others give you odd error messages and sometimes even result in the wrong page displaying? This is why.
It all starts with DNS, the Domain Name System. When you type a name in the address bar of a web browser it takes the server name and posts a query to your nearest DNS server. So for instance the URL http://example.com/somepage will result in a DNS query for example.com.
At this point, depending on how the domain was registered, the DNS will either respond with an IP address for example.com, or with a "not found" DNS reply. If there is no IP address record for the name you the browser will display a standard error page telling you that it cannot find such a site.
If the DNS responds back with an IP address, then the browser will attempt to connect and send an HTTP request to it. Here is where things tend to go wrong. HTTP supports a feature called virtual hosting where multiple web sites can be served by the same web server, using just one IP address. In order to distinguish between different sites living on the same server the browser sends an HTTP header indicating which site it wants to talk to. If the web server is not configured to correctly match up your request to a specific website hosted on it, it might return a default page (ISPs and large hosting providers tend to do that) or just serve the wrong website altogether.
If you are a webmaster and for whatever reason you wish to only have your website available when accessed using a www. prefix, you should ensure that your domain name does not have an A record. Most registrars will insert one by default when you first register a domain and so you need to remove it; only add an A record pointing to your web server against the www entry. That's it, now no one will be able to access your site without typing out the full name.
Most people will probably prefer to help their visitors out by allowing access via a shortened name as well. In order for this to work, you need to:
Make sure there is a correct A record against the base domain name
In DNS terms, this is called the @ record - the root of the specific DNS zone. So if your web server has an IP address of 192.168.0.1 the DNS zone should contain the following records:
@ A 192.168.0.1
www A 192.168.0.1
Make sure your virtual hosts are correctly defined
If you are using the popular Apache httpd web server you can use the ServerAlias directive to specify any number of alternative names to your site:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com w3.example.com
ServerAdmin webmaster@example.com
DocumentRoot /var/www/example.com
</VirtualHost>
Bonus: make sure your web server is set up to serve a default error page if it doesn't recognize the virtual host requested
What happens if someone mistakenly point a DNS name to your web server? In Apache, the first virtual host is the default one and if no server name or alias matches the request, that is what will get served. So if you are hosting multiple virtual hosts on your server, make sure the first virtual host you define points to a page containing some meaningful message stating that the site is not yet up.
Optional: rewrite the URLs to redirect visitors to your preferred domain name
If you would prefer your visitors to use one specific name for your site - e.g. for marketing reasons - you can use the following configuration to redirect those using the alternative name:
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / http://example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/example.com
</VirtualHost>
In this case you should remove www.example.com from the aliases.
Bottom line: make sure that whatever DNS records you do have are also configured in your web server. And unless you have a good reason not to, you should probably add the short domain name as a valid alternative.
Sushi and compact camera musings
I have had my Canon S90 for nearly a year! Quite hard to believe - in fact Canon has already announced an update is due out soon (S95). Apparently the rear dial doesn't turn freely anymore on the S95 but I haven't actually found that the loose one on the S90 has been the problem many feared it might be. I like that they've added extra holes for a proper neck strap though - that seems like it could be useful.
If there was one thing that would make me want to upgrade, it would be the ability to attach a dedicated optical finder. I know Canon would rather have me buy the G11 for that but those cameras are simply too big once you've tried the S90 (not to mention the lens is a stop slower!)
I would imagine such a device using a proprietary clip instead of the usual flash shoe to keep the size down; perhaps with an extra frame marked for 50mm FoV. It doesn't need to be super-accurate, although large and bright would be very desirable. For bonus points, the finder could incorporate a focus indicator LED and illuminated frame lines that switch as you zoom the lens - I'm sure many people would pay good money for this.
I often find that I am holding my camera up to my eye, zoomed all the way out and pre-focused, just trying to eyeball the correct framing. It works surprisingly well! Some enterprising users have already hacked (well, glued) finders onto the S90 but a first party solution would be far more elegant. Mike Johnston recently likened these cameras to the original Leica; I think a proper finder would really cement the argument.
Lightroom tells me that my catalogue only has about 750 shots from the S90. It's not much but I have some travels coming up so that number should go up soon. More importantly, I have a very large number of keepers - about 150 are marked 3+ stars - and most of these are in difficult low-light situations where most compacts would struggle to deliver much in the way of usable pictures. These are 150 shots I would not have made with my DSLR because it was sitting at home!
On a related note, I managed to drop mine a short distance onto some gravel. Luckily it escaped with nothing but a mark or two on the lens ring paint - easily sorted with some black permanent marker
The build quality (while not up to Leica M standards) is also more than adequate!
Shot info: f/2.2, 6.85mm (one step from full wide), ISO 1600, CR2 converted through Lightroom 3.
Quick and dirty web service testing
For command line geeks (on Windows the easiest way to get these utilities is to install Cygwin):
curl -s -d @request.xml -H "Content-type: text/xml" \
http://example.com/endpoint | xmllint --format -
Create a file request.xml with your XML input, pretty XML output will appear on the standard output. Curl is an HTTP swiss army knife, xmllint is a XML verification and manipulation tool.
SWI-Prolog has a sense of humor
Deep Thought jokes just never get old! SWI-Prolog, when asked an open-ended question for which no rules are defined, answers like so:
?- A. % ... 1,000,000 ............ 10,000,000 years later % % >> 42 << (last release gives the question) ?-
That's just awesome
Reminded me that I haven't (re)read HHGG in recent years - maybe I'll put it on me phone. Seems like the perfect book to read a chapter here and there when bored.
Nikon does fashion
Some random backstage and runway shots from Africa Fashion Week, taken last Thursday -
Shot with a Nikon D700 and a selection of fines Nikkors: 14-24/2.8, 24-70/2.8, 70-200/2.8 VR2, 105/2.8 VR. If I had to pick a favorite lens it would definitely be the 14-24/2.8, with the 105/2.8 VR Micro-Nikkor coming a close second. They are all, without exception, big and heavy lenses I wouldn't want to carry around all the time but they certainly produce the goods when needed!
