Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirect of complex URL structure to Wordpress

12:16 am on Nov 10, 2012 (gmt 0)

New User

5+ Year Member

joined:Feb 10, 2010
posts: 20
votes: 0

I would like to migrate my website with homemade CMS to Wordpress. My website has thousands of URLs in some patterns. Most of them look like www.example.com/something.php?id=XXX Is there any possibility to redirect these old URLs to Wordpress URLs? I haven't found any solution on this.

First I thought I could use IDs of old URLs. I could use old IDs as IDs of posts in Wordpress. I am afraid that it will not be that easy.

Thank you in advance for any advice!
1:53 am on Nov 10, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
votes: 403

Before you start, you have to find out what the equivalent Wordpress URL would be if the pages had been made in wordpress in the first place. And then you can figure out if they can be redirected in one step-- either via htaccess alone, or by detouring to a php script. The one thing you need to avoid at all costs is a double redirect. (Someone else hereabout said: the choice between an ugly url and a double redirect is like choosing between plague* and cholera. I firmly intend to steal this line and use it at every opportunity.)

You will also have to be careful with your htaccess, because any cms intallation-- including wordpress-- comes with its own htaccess. It main purpose is to rewrite the pretty wordpress urls to the "real" location of the information.

:: pause here for heated argument spanning next six posts ::

OK, still with us? If you can give your old pages the exact same URL that wordpress would have given them, they'll get scooped up in the same rewrite. Otherwise you'll have to code a separate rewrite, and be very very very careful that it doesn't conflict with wordpress's own rewrite.

* He actually said "pest", but that's a non-native-speaker thing.
8:19 am on Nov 10, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
votes: 0

This sounds like you need the "rewrite (that's rewrite, not redirect) the old requests to a special PHP script that looks up the new URL (either from an array or a db table) and then uses the HEADER directive to 301 redirect to the new wordpress URL" solution. It's been discussed a few times before and some of those threads have example code to get started.