I recently moved my blog from Serendipty to WordPress. During this long process I ran into a brick wall.
I had been intending to reuse all of my old URLs and place the new blog in the exact same place as the old blog but I encountered a problem.
The Serendipity blog allowed me to use some special characters in the url, this is something WordPress will not do. This was not a major issue as there are ways to have Apache rewrite URLs for you.
The big problem had to do with the fact Serendipity creates a URL with "index.php?/" in it. WordPress does not like the "?" in a URL.
I looked and looked all over the web but everywhere I went told me to put the URLs into a .htaccess file and reroute them that way. I tried that and... because of the "?" all links were being redirected without the argument that followed the "?".
So, if someone followed index.php?/cool-article or index.php?/not-so-cool-article they would all be dumped at the main page for my new blog! The redirect was redirecting the index.php request and ignoring everything else.
Being the resourceful programmer that I am I did some digging and found some PHP code that I could use that would grab the argument, remove any forbidden characters and redirect the reader to the right post.
Here it is, use it if you need it. Just to be sure to change the hmtk.com reference!
<?php
$page = basename($_SERVER['QUERY_STRING']);
$page = str_replace(',', '', $page);
$page = str_replace('+', '', $page);
$page = str_replace('!', '', $page);
$new_url = "http://www.hmtk.com/archives/" . $page;
header("Location: $new_url");
?>
- Blog conversion complete
- A note on my permalinks
- Change your domain the right way
- The forgotten side effect of moving to Propeller
- Amazon goes Contextual










Is there really any value to the search engines in this? Wouldn’t using a 301 redirect be the best as it would re-index the new page and remove the old page?
I tried doing the 301 redirect via the .htaccess file first. Because of the way the old blog was setup the redirects would not work as they would dump the name of the post (argument to index.php) and send the traffic to the blog home page.
Most of the search engines use my sitemap and have updated their links. The problem that remains is people who have old links bookmarked or links in old posts. I need these links to be properly redirected to where the content now resides.
You can do it easier within your code, I have actually used this on an article site as the .htaccess became to complex with a site move.
Before sending the heading info for the new location add the following:
header(”HTTP/1.1 301 Moved Permanently”);
Full construct:
so it would look like this?
$new_url = “http://www.hmtk.com/archives/” . $page;
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: $new_url”);
???
That should do it, I am a real 301 redirect whore! I really like to have all my link value placed to specific links. There is a new addition to google XML sitemaps that allow you to set the base domain, but why risk it.
Also, look into this plugin for wordpress, will append the “www” to your domain: http://txfx.net/code/wordpress/enforce-www-preference/
I tried using the header(”HTTP/1.1 301 Moved Permanently”); line and it choked on it.
To bad, I would really suggest trying to get it to work. How about some mod_rewrite directives? There is real power in doing redirect. Will literally redirect all you link value to the new page. The way you are doing it will require the search engines to re-index your content.
I am a bit rusty on the mod_rewrite and would have to look over some old sites to see what to do. If you are a member at digitalpoint forums, I suggest asking there. They have many users that have mod_rewrite skills.
The problem I encountered was the old links had “?” in them and the article was an argument to index.php.
I looked into mod_rewrite but I could not figure out how to make it work the way I needed it work. No matter what I did it ignored the argument and dumped people on my blogs home page.
True, if you aren’t using the same URLs and just moving directories, you almost have write a line of code for each page. Lots of work…
There is a wordpress plugin called Permalink Migration that does the same thing. I used it when I wanted to clean up my permalink structure.
This was a non-WordPress to WordPress conversion. Though I have not looked at this plugin I don’t think it would have worked for me.