the wonder of databases

so much fun to have databases integrated with this piddly site. moving to a new blog location left thousands of stale pages needing redirects to their new versions. years ago, using blogger, i would’ve used an offline database to create manual redirects, uploading thousands of replacement HTML files. but with wordpress (or any DB-based system controlled by user) those redirects simply became a local table, and i can get rid of the vast blogger folder structure while keeping unbroken whatever links go to the old blog — including when i linked to a post in another post, as in the first one linked below, with three links to old blog posts.

though complicated — because links sometimes deviated from a simple pattern — it was still a batch process except for roughly 200 records requiring manual cut and paste (in excel, data from which was easy as hell to import via phpMyAdmin).

here, test it out:

when, for example, you click http://saltypig.com/blog/2009/12/hollywood-eyes-record-10-billion-box.htm, the apache server

  1. sees that it’s from the old blog,
  2. calls the database for a search of roughly 2,400 old links and finds the matching record,
  3. grabs the new link from the next column in the table,
  4. redirects to the new page while sending a “moved permanently” message to the requester.

so

http://saltypig.com/blog/2009/12/hollywood-eyes-record-10-billion-box.htm

becomes

http://saltypig.com/2009/12/hollywood-eyes-record-10-billion-box-office-for-2009/

and

http://saltypig.com/blog/2004/06/everyday-squabble-in-crowded-subway.htm

becomes

http://saltypig.com/2004/06/an-everyday-squabble-in-a-crowded-subway-car-becomes-a-lesson-in-power-politics/

hard to believe how easy the geeks have made issuing SQL commands via browser. even batches with thousands of individual SQL commands were speedy, allowing me to handle the couple hundred manual problems in excel, string together SQL commands using those cells, and paste those commands straight to the browser and execute.

to continue the update spree, i could even use the link translation table to update old posts that refer to other posts on this blog, though i’ll probably save that for another day; those links are now redirected and unbroken, despite the original physical files having been deleted.

oh lovey, here comes thurston B howell III in your back door. i can’t control it, lovey! watch out, lovey! oh god

===
after, i thank deeply these wonderfully geeky people for providing code to snatch and modify or otherwise learn from.

Tags: , , , ,

Reply form

comments are enabled solely to discourage off-topic blather when i'm writing elsewhere. my wish is that no one comment here.

off topic? say it here or it'll be deleted. no spam. full censorship policy here.

update 20100729: generally, dunce comments from anonymous pussies no longer replied to. comments routed to spam queue may take weeks to publish, and sometimes be deleted accidentally from overlooking during review.

You must be logged in to post a comment.