Tech Note: LGF URL Makeover with mod_rewrite

• Views: 2,022

This weekend our aging, creaky, rather unfriendly URL scheme got an extreme makeover, courtesy of the Apache htaccess file and mod_rewrite.

The cool thing is that this redesign doesn’t break any old URLs; if you’ve bookmarked an LGF page, or if you follow an older link from another site, it will continue to work as always.

The old scheme used HTTP query strings, in that ugly sort of techie way you’ve seen many times; for example:

lgf.com

This would show an LGF front page entry on its own page, without the reader comments. After the revamp, this URL becomes:

lgf.com

Isn’t that prettier? And it has the advantage of being easier for search engines to index, too.

To show an LGF page with reader comments, the URL would be:

lgf.com

To show a particular comment:

lgf.com

Internally on the server, all of these new types of URLs are converted to their old style addresses with those ugly query strings, so none of the LGF code needed to change. Which is always good.

For the geeks in the crowd, here are the mod_rewrite rules that accomplish this feat of prestidigitation:

RewriteRule article/(.*)/comments/(.*) /article/$1$2
RewriteRule article/(.*)/comments/ /weblog/?entry=$1
RewriteRule article/(.*) /weblog/?entry=$1""http://lgf.com/weblog/logo.gif" data-fancybox-group="dfd54edd" title="logo.gif" class="image">Image: logo.gif”) can be found when the above URL redirection scheme is used. Without the BASE tag, the browser requests those files from inside a nonexistent folder named /article/.

But Opera (including the latest version as of this writing) doesn’t properly pass the base URL to Javascript Ajax calls. Apparently they need a little bit better communication between their HTML and Javascript engines.

The fix was annoying but relatively easy: just change the Ajax calls to use absolute path references to their scripts.

Jump to top

Create a PageThis is the LGF Pages posting bookmarklet. To use it, drag this button to your browser's bookmark bar, and title it 'LGF Pages' (or whatever you like). Then browse to a site you want to post, select some text on the page to use for a quote, click the bookmarklet, and the Pages posting window will appear with the title, text, and any embedded video or audio files already filled in, ready to go.
Or... you can just click this button to open the Pages posting window right away.
Last updated: 2023-04-04 11:11 am PDT
LGF User's Guide RSS Feeds

Help support Little Green Footballs!

Subscribe now for ad-free access!Register and sign in to a free LGF account before subscribing, and your ad-free access will be automatically enabled.

Donate with
PayPal
Cash.app
Recent PagesClick to refresh
The Pandemic Cost 7 Million Lives, but Talks to Prevent a Repeat Stall In late 2021, as the world reeled from the arrival of the highly contagious omicron variant of the coronavirus, representatives of almost 200 countries met - some online, some in-person in Geneva - hoping to forestall a future worldwide ...
Cheechako
5 days ago
Views: 153 • Comments: 0 • Rating: 1
Texas County at Center of Border Fight Is Overwhelmed by Migrant Deaths EAGLE PASS, Tex. - The undertaker lighted a cigarette and held it between his latex-gloved fingers as he stood over the bloated body bag lying in the bed of his battered pickup truck. The woman had been fished out ...
Cheechako
2 weeks ago
Views: 318 • Comments: 0 • Rating: 1