Recently, I modified the permalinks for my blog posts from: http://nizarnoorani.com/index.php/archives/%postid% to just be: http://nizarnoorani.com/%postname%
This new permalink structure will now apply to any new posts that I create. Which of course begs the question:
Will the links to all my existing blog posts break??
And the answer sadly and obviously is: Yes, they will!
Can we fix this unfortunate issue? Sure, we can! And there are quite a few WordPress plugins that do exactly this. A search for “WordPress URL migration plugins” will serve up links to many such plugins. One that I particularly liked and recommend is Advanced Permalinks.
If installing/activating/configuring one of these plugins fixes your problem – great! Things for me, however, weren’t quite so easy.
For some reason, which I still haven’t been able to figure out, none of the migration plugins worked for me! Maybe its because my blog was originally hosted under Windows and then I later moved it to Linux. Or maybe I wasn’t configuring the plugins correctly. Or maybe something else. I don’t know.
Anyways, IF you are in the same boat then here is one hacky solution to get your existing permalinks working again. Once again – Only do this IF you can’t get the WP migration plugins to work!
Okay, here goes:
- Log in to your WordPress Dashboard: http://yourwebsite.com/wp-login
- Set up your new permalink structure by navigating to Settings -> Permalinks. After you set up your new permalink structure, you’ll notice that your existing permalinks will now be re-directed to a 404 Not Found page. Browse to one of your existing permalinks to verify that this is the the case.
- Okay, time to put in our little hack to get the existing permalinks working again. Open up the WordPress 404 template page inside the WordPress editor by navigating to Appearance -> Editor and clicking on the 404 Template link on the right-hand side bar.
- Insert the following code snippet just below the
get_header()line:<script type='text/javascript'> <?php // extract the post_id from the URL. In my case, my existing permalink was of the // structure http://nizarnoorani.com/archives/%postid%. // modify the extraction code below for our particular structure as needed. $postId = (int)trim($_SERVER['REQUEST_URI'], '/archives/'); $post = get_post($postId); if($post != null) { // again, modify the URL as needed to match your new permalink structure. echo "window.location = 'http://nizarnoorani.com/".$post->post_name."';"; } ?> </script>
Note: Be sure to modify the code snippet to match your specific new and old permalink structures!
- Save your changes. Your existing permalinks should start working again!
Basically, what we’ve done here is added some logic to extract the post_id from the old link, retrieve the post with that post_id from the database, construct the new URL and then re-direct the user to the new URL.
Cheers!
WordPress on a GoDaddy hosted site – 500 internal server error!
- Is your blog site returning the infamous “500 – internal server error” more often than not?
- Are you using WordPress as your blog publishing platform?
- Are you using GoDaddy as your website hosting provider?
- Are you using IIS as your web server (as opposed to Linux)?
If yes, continue reading to fix this issue:
There is weird configuration issue with running WordPress with a IIS web server on GoDaddy. Taking the following actions will resolve this issue:
- Upgrade WordPress to the latest version. Detailed instructions at: Upgrading WordPress
-
Install WP-Super-Cache plugin. Here is the download link for it. In order to enable the plugin, you have to do a little tweaking. Below are the steps you need to follow:
- First off, extract the ‘wp-super-cache’ folder into your ‘wp-content/plugins’ directory.
- Log in to your GoDaddy account and navigate to Hosting -> Manage Account.
- Click on the Content tab and select File Manager.
- Here you will see all your files and folders. Check the wp-content folder and click the Permissions icon on the top. Uncheck Inherit and check the Read and Write checkboxes. Don’t worry this is only temporary to get your plugin working correctly. Save your changes.
- Now Enable the plugin by going to your WordPress Plugins page.
- Next you will have to enable caching. For this, go back to your File Manager and browse to the “wp-content/cache” folder. Change the permissions on this folder to Read/Write as well.
- Now open up the wp-config.php page that’s in the root directory and add the following line towards the end: define(‘WP_CACHE’, true)
- Go back to the Settings page for the wp-super-cache plugin and set the status to ON. Make sure to save your settings. You may see a warning about apache mod_rewrite not enable or installed. Don’t worry about this warning. This just means that your caching will only be HALF-ON which is fine because even it being HALF-ON will fix our ’500 – internal error’ issue.
- Go back to the File Manager and change the permissions on the wp-content folder to Inherit.
- Your website should now respond faster and stop generating the 500 – internal server error issue.
- As an additional security measure, I would also recommend installing the WP-SpamFree plugin. This is a very effective plugin that will eliminate virtually all SPAM comments. Thus decreasing the load on your website.
If that still doesn’t fix the “500 internal server error” issue, then try updating your current WordPress theme or switch to a different WordPress theme. If that doesn’t work either, then it’s time to bite the bullet and switch to Linux!

