This is a bit for my own reference and because I couldn’t find a useful link on this, so I hope that this page provides information that some would find useful. Apologies to my regular readers who may think this is a bit too ‘deep’.
Recently I changed all the Permalinks in a WordPress blog, and shuffled some things around. This resulted in a lot of 404 messages and file not found results for regular readers, or some coming from other links and search engines. So for some really important stuff I decided to put some permanent redirects in. However when I tried to redirect to the new permalink that WordPress provided, I was getting some weird error messages, so I sought an alternative.
Redirecting folders to WordPress Posts
This was a little easier than the next one, as WordPress 3.0 and higher helps you out by providing you with a shortcut URL.
For example, after saving the draft of this post, you can see under the title bar there is a button called “Get Shortlink”:
If you click on that button, you get a link like this:
So now I copied that URL to my clipboard and then went to my host’s cPanel.
I then go to the ‘redirects’ item (which you can find easily by using the new search option for cPanel):
Then I just fill in the directory that I want to set up the permanent redirection for (eg. http://myblog.ozlady.com/some_directory redirects to http://myblog.ozlady.com/?p=1999) – see in the screen shot below.
Click the ‘Add’ button, and you’re done!
Redirecting folders to WordPress Pages
This one is almost identical to the redirect for WordPress posts, however for WordPress pages, I found it a little trickier to find the shortcut URL.
To do this you will need to find the Page number. To do this, go to the pages listing and ‘Edit’ the page that you want to redirect to.
In the URL at the top of the ‘Edit Page’ page you will see something link this:
Note down the number next to “post=” (in the instance above it is 166.
Now you will need to use that number and insert it in a pages URL which is slightly different from the one we used in the posts example.
Notice that we use ?page_id= instead of ?p=
This can then be entered in the cPanel Redirects page as follows:
Click on ‘Add’, and you now have a redirect to a WordPress page.
If you know of an easier way to do this, please let me know, however in my case I found that the permalinks provided by WordPress that would appear in the address bar were kicking me with error messages, and this was almost fool-proof.
Back to regular programming now!