How I Fixed That Annoying WordPress Permalinks Issue

I detailed here an annoying issue with Kikay Ex that happened after the Big Server Move a few weeks back. For some odd reason, after the move all the previous internal links were appended with ‘index.php’. For example:

what used to be


The problem was that I was using a wp-plugin called ClickCounter which is attractive because if you mouse over a link, a little message will popup showing how many times it’s been clicked, like this:

It’s not completely reliable (it doesn’t count right-click ‘open in a new window’, for example), but it at least gives a fairly good representation of how popular a link is. A good guess, I suppose, is that it misses approximately 20% more clicks.

At any rate, another thing that plugin can do is come up with a ‘Most Clicked Links’ list. It saves it all in MySQL making it a terrific database hog, but hey I don’t care, that’s what I pay my host for. So anyway, ever since the permalinks issue, it obviously completely screwed up the internal links count (it didn’t affect external links), and aside from that, ‘Most Clicked Links’, which I display on the sidebar, was showing off internal links that lead to 404 pages!

The obvious response was to reset Permalinks which I tried over and over, to no avail. I kept trying to remove ‘index.php’ and revert it back to before, but it wouldn’t go. And in the meantime, precious links were getting counted in the new Permalink structure, so if I reset it, I was gonna lose those.

In other words – I had a disaster.

So today, I decided I wouldn’t quit until I licked it. I installed the plugin last year so it took me awhile, but after reading the HowTo I realized it relied on a MySQL table called wp_linkclicks. After I downloaded it in sql format, I saw the culprits right here:

There it was. Internal URLs without the index.php appended to them. I was actually thinking of just changing the URLs of the popular links, like the ‘kikay cams’ link above and some others, but I realized what the heck, let’s change all the internal links. So I replaced all the 2006 posts here:

and all the 2007 posts here:

I then dropped (deleted) the wp-linkclicks table (making sure to save a fresh backup of course. Kids don’t try this at home unless you know what you’re doing), and then uploaded my new, appended one with the ‘index.php’:

and VOILA! My Most Clicked Links is counting again, starting where it left off so that I wouldn’t have to reset the damn thing and lose all of those precious ‘This post has been viewed xxx times’ stats, some of which are almost in the thousands by now.

Whew. Now there is another issue about fixing it so that old links that have been posted outside of Kikay, when clicked, need to go to the proper page. I’m sure htaccess will be the one to address this, and I’ll try to post here the results of that.

Anyway, I think I wasted a few braincells fixing that up, so I’ll go eat something now.

Leave a Reply

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