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.
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.
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.