Url hack for Lifehacker hashbang linksTuesday, April 26, 2011
Gawker's geo-redirection is causing problems. Their main .com sites use hashbangs, but their country-specific ones don't. Traffic coming into the .com sites from countries with their own country-specific subdomains are redirected on the first attempt.
That geo-redirection changes the domain name, but doesn't fix the hashbang URL, so the visitor is thrown to the homepage of that domain rather than the article the link was supposed to point to.
One solution is to hand-edit the URL each time by removing the hashbang characters. The other is to go back to the originating page and click it again and hope the second time the geo-redirection doesn't kick in.
Fixing the problem
Three months without fixing this is ridiculous. And it's not difficult. So I've gone ahead and created a fix myself. Gawker are welcomed to take this code and implement it on their servers.
The solution is straightforward, the complicated part is trapping queries to the Gawker sites. It would be easier if I had control over the gawker domain namespace, but I can work around that.
Lets go step by step. The IP address of my VPS is 188.8.131.52 (this is actually my development/playground VPS).
Step 1: mapping Gawker domains to my VPS
On a Mac or Linux boxes this is a case of editing
/etc/hosts. So in a terminal running
sudo nano /etc/hosts and adding the following line:
184.108.40.206 lifehacker.com gizmodo.com
On Windows the corresponding file is
/Windows/system32/drivers/etc/hosts. Make the same edit to this file with your text editor and save. Windows users have one extra step to perform here: close down your browser and reopen. This will clear the domain name cache and allow this change to take effect.
Step 2: Click on Lifehacker links like normal
There is no step 2.
Replicating this on your own VPS or webspace
The default configuration on a Ubuntu server is to map all non-specified domain names to the default webroot (
/var/www), so all non-specified pages are served up
/var/www/index.html. So I'm using this little trick to make it easy to deal with gawker domains without any configuration. All I've done is replaced the starting
index.html with a PHP script that checks the domain name of the incoming request.
The script is as follows (running at
Fixing the web a little at a time
This solution solves my two main headaches with the Lifehacker site:
- Gawker breaking incoming links to articles
- Having to deal with that abysmal Gawker Ajax interface
I should not need to do this fix. Gawker seem to have no inclination to fix it themselves. I reiterate: hashbang URLs break the Web, here's one datapoint.