Seamless Permalink Updating

by Rick Beckman on January 13, 02008

Update: The solu­tion to the prob­lem in this post has been found and posted.

I wish I would have set up the perma­link struc­ture here prop­erly months ago when I started blog­ging. Now I want to change it, but if I am not care­ful in doing so, I’m effec­tively los­ing any exter­nal links to my posts, par­tic­u­larly those the search engines have linked to.

What I mean is, I want to go from this:

http://rickbeckman.org/2008/01/08/refactoring-rickbeckmanorg/

to this:

http://rickbeckman.org/refactoring-rickbeckmanorg/

with­out mak­ing the first link ineffective.

I know this can be accom­plished via mod_rewrite, but I’m by no means savvy enough to fig­ure it out. I’ve exper­i­mented, I’ve read all about reg­u­lar expres­sions, but I have as of yet been unsuc­cess­ful at wrap­ping my mind around the con­cepts involved.

I do know that I need to rewrite /number/number/number/text-numbers-hyphens/ to sim­ply /text-numbers-hyphens/.

Seems sim­ple enough, but for all its won­der, mod_rewrite is strange voodoo.

Any­one read­ing this skilled enough to lend me a hand? I asked on the Word­Press sup­port board, but I did so not­ing that sev­eral other users with sim­i­lar ques­tions haven’t received any real help in ten or more months. Need­less to say, I’m not hold­ing my breath either.

{ 11 voices in the conversation. Speak up! }

Chris January 13, 2008 at 13:26

I’m probably at the same point as you as far as understanding mod_rewrite. I played with it a couple years ago and ended up messing up all my links and my photo gallery (should have done a test site like you…lesson learned). I’ll let you know if I run across anything that can help you out. It’s strange voodoo indeed…

Curious…why the change? Speed up the site?

Rick Beckman January 13, 2008 at 14:47

Actually, the change will have a twofold effect:

1) The URLs will be more attractive to human users — example.com/article/ is a lot nicer than example.com/year/mo/da/article/. Just seems cleaner, perhaps more professional. Though admittedly, that’s quite subjective!

2) The date of the post adds nothing of value for search engines; removing it will increase the power of whatever is left in the URL, concentrating the power of the keywords present, so to speak. I’m a sucker for SEO tips like that, I suppose. :)

Jeff_ January 16, 2008 at 18:21

I recently contemplated doing the same thing, but voted against it primarily because I felt the hassle just wasn’t worth the payoff, which, unfortunately, is probably not much. Nonetheless, I am going to look into a “clean” way of doing this via htaccess as soon as possible. If/when I am able to cobble something together, you will be the first (- er, second) to know. ;)

Rick Beckman January 17, 2008 at 07:36

As I stated over at your place, I will be greatly appreciative! It’d be nice to have a real solution to this problem, whether the payoff is substantial or not. :D

Donace January 17, 2008 at 15:16

not sure what version (think it was 2.3) my mate had running on his site and he had similar permlinks.

I was snooping at his backend and found that you could add a custom setting.

I set it up as /%category/%title and it ended by having url’s as follows:

Post
http://example.com/funny-videos/light-sabercarefull

Category
http://example.com/category/blondes-jokes

A few kinks as you can see by the second url but i hope to iron these out and will experiment later with htaccess but my knowledge is limited but i will let you know if i find the grail.

Rick Beckman January 17, 2008 at 20:29

Donace — Changing the permalinks the system creates is quite easy, yup. The problem I have is that as soon as I change my permalink structure, any links which reference the old style — including those within search engine indexes — will be invalidated. I’m looking / hoping for a way to seamlessly redirect any requests for old style permalinks to the new style, which I hope to implement soon.

Jeff_ January 20, 2008 at 11:17

Looks like you beat me to the punch! Your permalinks look much cleaner now, I must admit.. How has the htaccess code been working? Any issues? Have you examined your 404 error log since the change? I may just have to rethink my permalink strategy (again) after all..

Rick Beckman January 20, 2008 at 14:04

Jeff_ — Actually, I never checked Apache’s error log until I implemented this change; I’ve been checking it pretty much daily since doing so!

And so far, everything has been working great. What is a mystery to me is how the permalink to the post RickBeckman.org » Kingdom Front works; the permalink to it contains two percentage signs, which wouldn’t be caught by the regex I’m using. Yet the permalink seems to work just fine, so I’m not getting worked up about it by any means.

Nikhil Gupta May 18, 2008 at 00:24

hey rick, there is a small problem i am facing here…
I use google webmaster… and it still shows me indexed sites from the time when i was just setting up my blog, (i mean i was experimenting from Joomla, wordpress, etc) later, i used wordpress with no permalink updates.. now google webmaster shows me links from the Joomla time, as well as Wordpress’s non-seo permalinks… how to delete the Joomla links and how to update those wordpress links to the current ones…
Please help me…

Latest from Nikhil Gupta: 1000 Megauploads Links’ List!

Nikhil Gupta May 18, 2008 at 00:25

I m sorry… dont wanna spam… but did my comment went through….???

Latest from Nikhil Gupta: 1000 Megauploads Links’ List!

Rick Beckman May 18, 2008 at 16:22

Nikhil Gupta: Removing content from Google can be done in a variety of ways, but all of them will take place at Google’s own pace as its crawler discovers that the content is missing or forbidden:

http://www.google.com/support/webmasters/bin/answer.py?answer=64033&topic=13511
http://www.google.com/support/webmasters/bin/answer.py?answer=61062&topic=13511

As far as getting your new content indexed, if Google’s crawler can crawl your site using the new address structure, those addresses will be indexed.

The addresses your site used prior to the permalink settings were like this, correct?:
http://isthisnikhil.com/?p=4

If that’s the case, try visiting that old address; it redirects to the new structure just fine, so Google should see that when it tries browsing your older style addresses and it will update accordingly.

Leave a Comment

Previous post:

Next post: