There was a Tweet that was going around today:

This is what happens when u don't update a WordPress slug: RT @ Read the headline first, then the URL.
David Bisset

So the URL of the story was:

And the idea is that this was the WordPress title as the author composed the story, but then (of course) changed the title before publishing, but never updated the slug (permalink).

Well, that’s total BS, but a great story. What’s really going on is an SEO trick in which what comes before the number doesn’t matter at all, and is used to put keywords in the page name. I do the same thing with my datafeed sites – only I make sure if someone changes the keywords, it goes to the correct page. Simple enough fix:

$cPHPSELFExpected = '/' . simplify($rsMerchantData['cName']) . '-m' . $rsMerchantData['nMerchantID'] . '.php';
if ($_SERVER['REDIRECT_URL'] != $cPHPSELFExpected) {
	header("Location:  $cPHPSELFExpected", TRUE, 301);
} // ends if ($_SERVER['REDIRECT_URL'] != $cPHPSELFExpected)

I figure out what I expect the page to be, and if I’m not there, do a permanent redirect to the page I expect to be at. simplify() is a function I created to remove spaces & special characters, make things lowercase, and combine the phrase with dashes.

So if you’re running a datafeed site, make sure this little bit of code is in place to ensure your users are all seeing the same URL.

1 Comment » for Fix Your Permalinks
  1. Thanks Eric – I just learned a useful tidbit, but at the expense of the enjoyment I got out of thinking that was authentic. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *