I currently have my wordpress blog (apache2, ubuntu linux) hosted at e.g. mysite.com
using ID-based linking, e.g. http://mysite.com/?p=547
. I have two goals:
- move my blog to
mysite.com/blog
- change the link structure to
/{post-title}
instead of/?p={post-id}
Moving to the new structure should be simple enough, as is changing the setting in wordpress to use the new permalink structure.
What I would also like to do is not break the random(1..100)
sites that currently link to me. I would like to use an HTTP 301 permanent redirect, but I'm not sure how to do that by changing apache's settings.
The first issue will be to handle the redirection to /blog/
for all requests.
The second issue will be to handle the new link structure. I figure I can query the mysql database easily enough and generate something like ?p={post-id} > {post-title}
, but I'm not sure what the syntax should look like and where I need to put it.
Any help would be much appreciated.
When you change the URL scheme from p=123 to post-title, wordpress will automatically 301 visitors from the old ID URL's to your correct url - so that's sorted out.
Next, since your stuff is reached via ?p=[0-100] then you could quite easily take care of this via PHP. There are 2 solutions as I see it - one is a bit more elgant than the other.
Write some code that looks into the Wordpress database according to the pageid in GET, and 301 the user accordingly.
Do a 1 to 1 301 redirect, something like
The above code is untested, but should illustrate the idea. The above code will in many cases cause 2 301's - but as far as search engines, it should only send them through the 301 twice and make them update their URL's.
Bookmarks - you can't do much about those.