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.]

60 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

  24. georgiy Says:

    pishite esche na podpbnue temu

  25. nikolay Says:

  26. leon Says:

    ,

  27. Jones Says:

    Неплохой блог, почитал - добавил в закладки, пишите побольше, буду следить по рсс.

  28. Lawson Says:

    Интересно пишешь - добавил блог в ридер

  29. Kevin Says:

    tested, works with WordPress 2.7

  30. ShoobbyNot Says:

    У вас RSS в кривой кодировке!

  31. Expavy Says:

    Я бы сказала о монументальности, грандиозности некоторых сюжетов. А назвала бы - “нефильтрованный реал”. На мой взгляд, красота - это все-таки другое: лучшее, чистое, избранное, заставляющее трепетать и поражаться. Можно найти красоту во всем, но всё скопом - не есть красота. Имхо.

  32. Assevy Says:

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

  33. Вилен Says:

    Я тоже в блоге про такое пишу, только на тему фильмы

  34. Mayogs Says:

    Спасибо. Просто спасибо, за красивые мысли вслух. В цитатник.

  35. Cheessysed Says:

    Огромное человеческое спасбо!

  36. borya874 Says:

    Здравствуй! Спасибо за подаренные хорошие эмоции…

  37. erit774 Says:

    Зачет, сенкс автору

  38. chasePap Says:

    На Ваш блог знакомый в аську ссылку кинул. Оказалось ,что не зря Понравилось. Тепрь постоянно читать буду

  39. gosha587 Says:

    Захватывающе

  40. nnm7773 Says:

    Здорово!

  41. Erathe Says:

    Добавил в свои закладки. Теперь буду вас намного почаще читать!

  42. insadayliaib Says:

    Спасибо за статью. Восхищена как всегда

  43. Trourb Says:

    А у вас пара ошибок в тексте… тока не обижайтесь )

  44. lasder4 Says:

    Достаточно интересная и познавательная тема

  45. botpari3 Says:

    Жаль не мое…..

  46. Serjio Says:

    Как можно связаться с автором блога для размещения постового у вас на сайте и сколько будет стоить?

  47. klopig Says:

    Добавил в закладки. Теперь буду почаще читать!

  48. Falsheersnah Says:

    Классно всё: и картинка ,и информация

  49. apaceWeria Says:

    По правде говоря, сначала не очень то до конца понял, но перечитав второй раз дошло - спасибо!

  50. aparee Says:

    Можно и подискутировать по этому поводу …

  51. biloper Says:

    Действительно то что надо! А то сколько не лазишь по нету сплошное бла бла бла. Но не тут, и это радует!

  52. Natawaiday Says:

    От безбожья до Бога - мгновенье одно.
    От нуля до итога - мгновенье одно.
    Береги драгоценное это мгновенье:
    Жизнь - ни мало, ни много - мгновенье одно!

  53. shephene Says:

    Можно и подискутировать по этому поводу …

  54. cissatsMaW Says:

    Благодарю!!!У Вас часто появляются очень интересные посты! Очень поднимаете мое настроение.

  55. appeamidyek Says:

    Я уже сегодня писал вам по поводу продаи (цены) вашего домена. Но зашёлш из дома провертиь ваш ответ, а своего комментария так и не обнаружил. Видимо, я его как-то не так отправил, или у вас спам-фильтры зарубили мой комментарий, я на всякий случай поменял указанные е-мейл, ник и сайт, вдруг они не нравятся вашему фильтгу.

  56. VietsMig Says:

    Классно всё: и картинка ,и информация

  57. Joftbife Says:

    Я в принципе, мало, что смыслю в этм посте, но постараюсь все таки понять.

  58. appeamidyek Says:

    Достатно интересно конечно. Хотя я немогу подписаться под каждым словом, но в общем соглашусь.

  59. benfleliA Says:

    Это переходит все границы.

  60. Павел Says:

    Да все понятно, Спасибочки за пост.

Leave a Reply