WordPress versus the Long URL Post Slugs, or How I finally got my really, really, long WordPress URLs to work just fine, even when they get broken in email.

FlexURL is a plugin to help readers find your blog even when then the URL has been word-wrapped in someone’s email.

Yikes, what a title, eh? For those of you who know, Google loves keywords in your URL. For those of you who don’t, I won’t be explaining it here.

But this is the reason my Permalinks format is /%post_name%/ and nothing else. I write long descriptive post titles to get Google’s attention. And normally this is no problem because nobody types URLs in manually anymore. Trackbacks work, links work, etc.

But what about email? You’ve all seen this one, right?

From: frood28973@twc.rr.com
Subject: Windows problems on April 12?

It was in the paper last night. Can you guys believe it? Here’s the link:
http://www.askdavetaylor.com/why_are_windows_people_calling_april_12_
updatecrash_day.html



Yahoo! Groups Links

  • To visit your group on the web, go to:

You see the problem right away. The link is broken. You might get lucky and find the article by clicking on it, because not all of the URL may be relevant. If it doesn’t work, you know how to fix it. But there will be at least a half dozen follow-up emails on the list complaining about the broken URL. Then there will be another half dozen explaining how to type the whole URL in. Then at least one person will send the “corrected” link, only to discover that it got wrapped too.

But what if the link is to your blog? Or worse, to my blog!

I want people to be able to find my blog entries when they’re cool enough to get emailed, even if the URL is too Googular to fit into anyone’s email app, newsgroup autofilter, etc.

In short, I want all these URL’s to work the same:
http://www.philhord.com/phord/his-dark-materials-the-golden-compass-the-subtle-knife-the-amber-spyglass/
http://www.philhord.com/phord/his-dark-materials-the-golden-compass-the
http://www.philhord.com/phord/his-dark-mat

In fact, if the first part of the URL matches one and only one post, I want that post to be the “found” post for that URL. If the first part of the URL matches more than one post, I want all those posts to be found and listed.

Enter the FlexURL plugin. My friend Leo who has a Technical Questions site came up with this idea and implemented it on his blog. After he described it to me (and after I got over my awe at the simplicity of the idea), I set about implementing it on WordPress.

It wasn’t easy, actually. The plugin is very dependent on the internals of WordPress. So I set it aside for a few weeks and promptly forgot about it. Then another friend of mine and Leo’s, Dave Taylor of AskDaveTaylor.com fame (a great Tech Support site), announced that he had implemented his own version for his blog. I couldn’t let this challenge go unanswered, so I got back to my plugging in. And FlexURL is the result.

FlexURL only works on WordPress 1.5 and later (but see below for a 1.2 solution). I’ve tested it on 1.5, 1.5.1.2 and 2.0 [updated entry: 03/15/2006]. It works fine on all of them. But please use caution. After you activate FlexURL, please check the rest of your site and make sure it all works. The hooks I’m snooping are powerful and could cause problems. Let me know if you see any. (By the way, any problems you do see should go away when you Deactivate or delete the plugin.)

I still consider this beta software. This has worked well for me for a long time, now. [update: 03/15/2006]
Here’s the plugin [download] and in source form .

Install it in the usual way:

  1. Copy the file to your wordpress/wp-content/plugins directory.
  2. Open your WordPress Admin control panel and click the Plugins button.
  3. Find FlexURL and click on its Activate button.

[Update 03/15/2006:  changed wording to reflect WP 2.0 compatibility.  Also, updated plugin code to work around problem with some people’s .htaccess setup.]

23 Responses to “WordPress versus the Long URL Post Slugs, or How I finally got my really, really, long WordPress URLs to work just fine, even when they get broken in email.”

  1. » FlexURL for WordPress 1.2 -- from the mind of Phord Says:

    […] the mind of Phord Hobbies, family, homeschooling, life and stuff « […]

  2. phord Says:

    Update: Version 0.2 now redirects to the correct URL instead of showing the data on the “broken” URL page.

  3. jez Says:

    As I posted below another post of yours,
    I love flexURL, but it doesnt work for me:

    All I get after activating and then clicking on some post is:

    Warning: strtotime() [function.strtotime]: Called with an empty time parameter. in /home/www/web3/html/wp-includes/template-functions-links.php on line 48

    Warning: Cannot modify header information - headers already sent by (output started at /home/www/web3/html/wp-includes/template-functions-links.php:48) in /home/www/web3/html/wp-content/plugins/FlexURL.php on line 90

    Warning: strtotime() [function.strtotime]: Called with an empty time parameter. in /home/www/web3/html/wp-includes/template-functions-links.php on line 48

    Warning: Cannot modify header information - headers already sent by (output started at /home/www/web3/html/wp-includes/template-functions-links.php:48) in /home/www/web3/html/wp-content/plugins/FlexURL.php on line 91

    any idea?

  4. phord Says:

    The “Cannot modify header information” error comes because you likely have extra lines or spaces at the beginning or end of FlexURL.php. Edit the file in a decent editor (vi?) and remove any extraneous info after the closing php line. Try this thread:
    http://wordpress.org/support/topic/30278

    I don’t know where the Empty Time error is coming from. I don’t think that’s the FlexURL plugin. Try disabling FlexURL and see if the problem abates or not.

  5. Emily from How to Blog Says:

    This is EXACTLY what I was looking for — but does it work with WordPress 2.0+?

    Please say that you have updated the plugin (or plan to soon)

    TIA

  6. phord Says:

    Yes, it works on WP 2.0, which is what powers this here blog. :-)

  7. markofando Says:

    Want to start your private office arms race right now?

    I just got my own USB rocket launcher :-) Awsome thing.

    Plug into your computer and you got a remote controlled office missile launcher with 360 degrees horizontal and 45 degree vertival rotation with a range of more than 6 meters - which gives you a coverage of 113 square meters round your workplace.
    You can get the gadget here: http://tinyurl.com/2qul3c

    Check out the video they have on the page.

    Cheers

    Marko Fando

  8. Vellgolopsy Says:

    I’ve got an Amazon gift certificate burning holes in my pocket,
    and I want to get the most bang for my buck.

    Enter the Secret Amazon Web Pages:

    http://tinyurl.com/38sojf

    This is where you’re going to find the “latest sales, rebates, and limited-time offers” from
    Amazon, and you can score some pretty deep discounts if you’re a savvy shopper.

    Next, there’s the special Sale link. This is open every Friday, and ONLY on Fridays.

    You can find the same good discounts here as you would in hidden Deals, although some
    Fridays you can really get lucky and make off like an Amazon bandit - I’ve seen discounts
    there as low as 75% off sticker price.

  9. Bibingiof Alaksf Says:

    Hey! This is really your Work?! Cool! I never earlier did not see sites like this! Tnx!

  10. James Kryten Says:

    Hello! I am thoroughly impressed with your knowledge of Computer Science. Your insights into this article about Computer Science was well worth the the time to read it. I thank you for posting such awsome information. Signed James Kryten on this Day Thursday.

  11. Halo Says:

  12. megaprom Says:

    M .
    :



    . .

  13. Ozh Says:

    This plugin is useless, this is WP’s default behavior since 2.2 or something.

    Example:
    http://planetozh.com/blog/about-plugins/ is naturally redirected to
    http://planetozh.com/blog/2008/06/about-plugins-and-roles-in-wordpress-mu/
    and I’m not using any plugin for this.

  14. Светик Says:

    Вообще, честно говоря, комментарии тут гораздо занимательней самих постов. (Не в обиду автору, конечно :) )

  15. Andreyka Says:

    Интересная статья, кстати автору хочу предложить установить от яндекс.денег полезную фишку на сайт “Дай рубль”. Я бы дал, так сказать на поддержание. ;)

  16. Игорь Says:

    Блин, не совсем согласен, но почитать было любопытно.

  17. Степан К Says:

    Люблю сообщения в таком духе! Премного благодарен :)

  18. Delphi Says:

    Ссылка на файл битая

  19. marvel Says:

    Good 235rter2rwer23r

  20. miriam Says:

    Good 235rter2rwer23r

  21. Электронные книги Says:

    Плагин обрезает URL страницы или Url в комментариях?

  22. Dorothy Beckmann Says:

    I do have 1 problem though, i have applied this theme to my blog and it works great on safari and firefox but for some reason on internet explorer it does not work properly, the menu bar with the different tabs is over to the right, if anybody knows how to fix it could you contact me at sean@leateds.com or just here on this blog post.

  23. askar Says:

    cool, clasno pishesh, prodolzhay v tom zhe duhe

Leave a Reply