One of the most frustrating aspects of writing a computer book is providing pointers to useful information on the Web. We have a lot of URLs in this book, and most are long and random – expecting the reader to type in one of these URLs from the printed edition isn’t all that realistic.
Not only that, but URLs decay over time. I’m in the final stages of updating Windows Security Inside Out (delayed a few months from the original publication date and now scheduled for release in September/October). Many of the Web pages we pointed to in 2002, when we wrote the first edition of this book, have changed. A few Webmasters provide redirects, but most don’t.
One possible solution for this dilemma is to provide URLs that redirect to the actual page. Third-party sites like tinyurl.com and snipurl.com already do this. The advantage is that those long, impossible-to-type addresses get cut down to manageable size.
I’d like to do something similar, but without having to rely on a third party. My vision is a Web page where I can maintain a simple database consisting of a page name, description, original URL, and short URL (the short URL would be a simple four- or five-character code, which would be tacked on to the end of my domain name). I would create this list as I work on a book, so that the URLs published in the book would point to the short URL and redirect to the proper page.
If a page gets moved, I can change the redirect code so that it points to the new location. If a page disappears, I can point to a cached copy of the original or to an alternate source that contains the same information. I can publish the master list of resources on a page that’s available to anyone.
Anyone know of an off-the-shelf package that does something like this? If not, any suggestions on the best way to build this kind of application? Leave a comment or send me an e-mail.
How about Frontpage?
Not trying to be funny here, but what you’re attempting is simple enough: a web based list of links. Why don’t you create a simple home page, one sub-page per chapter of your book, and on each sub-page, properly referenced, you provide the URLs?
Thanks for the suggestion, Hubert.
That’s one way of doing it, but it puts the burden on the reader to enter the URL for that chapter, find the corresponding link, and then click it. That’s a little better than having some godawful long URL in the book, but it’s still not friendly enough.
As a reader, I want to be able to type in a short URL and get redirected to the page where I want to go. I suppose I could hack around with FrontPage or a similar site management program and get it to do the redirects for me, but I’m hoping that someone else has already had the same brainstorm and I can just use their code.
I’ve implemented this on a couple of my sites, although I’ve used it to redirect users from old content locations to the new URLs on the same site, not to manage external links. For instance, see this URL, which doesn’t exist as physical file on the webserver. It’s instead just an entry in the redirects database.
Getting the webserver to interpret a URL that doesn’t exist (edbott.com/23) instead of a URL with a GET string (edbott.com/link.asp?id=23) is easy: in IIS manager, you just map the custom error 404 to a new file you call 404.asp.
That file looks up URLs in a database (even an Access database will do) and redirects the users using Response.Redirect. I’d give you my code, but you seem to not be running IIS, and I don’t write PHP…
Thanks, Ryan. You’re right, it would have to be PHP, and the solution you’ve come up with is exactly what I’m looking for, conceptually. Hmmm. I suppose I could hack something together with a little study. For someone who already knows PHP and MySQL, this should be child’s play. (Easy for me to say, right?) Anyone out there with the qualifications who wants to try to put something together?
I’ve got some redirects on this site, but for a book project, the total number of URLs in the database would probably number in the hundreds, which is too many to manage manually.
A List Apart has a good article for PHP, with everything but the code to access the database.
I like the PC World’s Find page. I’m sure you’ve used it, too. Maybe they would tell you how they do it.
You want to point the urls to your own site and use mod_redirect or mod_rewrite, assuming you’re running apache. No need to code it in php when the functionality already exists in apache.
Welp, this was an interesting idea. Since I hadn’t heard of a pre-packaged system for doing this, I decided to write one myself. It’s a very rough example, mainly meant to be used as a starting point (particularly since I have no use for it).
You can find the example, as well as all the source code here: http://dacnomm.com/simpleurl/
As the page says, if you need help, drop me an email!
ed,
hi, i talk about how yahoo.com and webreference.com use mod_rewrite to auto-abbreviate urls in my book, Speed Up Your Site (chap 17 i believe), as well as in an article at:
http://www.websiteoptimization.com/speed/tweak/abbreviate/
andy
Several people have mentioned the use of Apache modules to fix this problem. While that would certainly work, I’d personally prefer the PHP / MySQL solution I came up with for a couple reasons:
1) I don’t know how to use mod_rewrite. I know it’s not difficult, but off the top of my head, I don’t have a clue.
2) Requires Apache, while the PHP / MySQL solution should work on IIS as well.
3) Many hosts (assuming you’re using shared hosting) won’t give you access to the Apache config file, and might lock down .htaccess as well, so you wouldn’t be able to use mod_rewrite.
PHP and MySQL may not be the most efficient solution in a couple ways, but it’s certainly got the broadest range of coverage, not to mention it’s incredibly easy…
There’s a similar discussion worth reading on Chris Sells’ blog;
I’ve left some comments on Chris’s post regarding the general problem and approach, but I may have a specific solution as well.
My firm has developed a .NET-based platform (dubbed “Liquid”), which essentially replaces the traditional webserver URL-resolution mechanism with a custom database lookup. It uses regular expressions to match and parse URLs, and to decide which handler class to load for each request; for example, any of;
http://books.edbott.com/mybook1/p123
http://www.mybook1.com/p123
http://books.edbott.com/mybook1/pg123
http://books.edbott.com/mybook1/p 123
http://books.edbott.com/mybook1/page 123
Can be regex-matched and parsed as book=mybook1, page=123, then passed off to a ‘BookPage’ handler for the HTML rendering.
Individually numbered URLs would be similar;
http://books.edbott.com/mybook1/123
http://www.mybook1.com/123
http://books.edbott.com/mybook1/url 123
http://books.edbott.com/mybook1/urls/123
And you can simplify entry by offering a book mainpage with a “type in the URL number here” entry area.
I currently use the system for very large affiliate programs where millions of discrete URLs are required, but the system has a lot of other applications.
I’ve been giving a lot of thought to the “hand-typed-URL” problem and am working on ideas for how to develop a service for book authors, publishing houses, magazines, newspapers, radio stations, direct mail campaigns, etc.
If the self-hosted PHP approach isn’t a rigid requirement, and the rough concept sounds like a fit, maybe we should consider an experiment.
Have you tried shorty? It’s a php script to make links shorter. Check it out http://get-shorty.com/