Support » Fixing WordPress » Change domain AND permalinks in one redirect?

  • Okay, the time has come to move CHAITGEAR from to (which is a different box…). At the same time I do that, I am updating my core code (from 1.0a to a 1.5.2-esque branch), and want to turn on nice-URIs.

    So, I know all about moving sites from the physical side (i.e., moving the DB, changing wp-config, changing entries in the DB to match the new domain name). I’m also already running a test 1.5 system here at home that’s synced with my live 1.0a site, so I know the ‘upgrade’ process will work fine.

    But, I need to do two things:

    1. when a request comes in to, I want to redirect it to IN MOST CASES. There ARE a few posts (notably my own WP plugins) that I will likely want to keep hosted off, but maybe in So I potentially need some tricky rewrite rules (I’ll do em if someone can ‘template’ for me) to hand certain redirects to new locations on, and all the rest to the new home on

    2. when redirecting, I want to redirect to a new nice-URI/permalink format. probably /arc/%postname% for articles and /cat/%name% for categories, and possibly all under /wp/ to keep the upper directory cleaner. 😉

    I know there are plugins which do some part of this, but not sure they’ll do the job. Don’t know if I should do this in htaccesss on, or via a custom index.php (or plugin) on that hands back the 301 redirect.

    I am also (for anyone who knows me) obviously capable of writing custom PHP redirection code, or adapting one of the available plugins to do the work… I just don’t know where to start!

    Thanks folks,

    -David Chait

Viewing 3 replies - 1 through 3 (of 3 total)
  • Oh, I should have made clear two other things:

    1. I intend to keep alive for some time to come, as a LOT of people have it linked — but will change my top-level index.php to a new static (or mostly-static) homepage, with redirects (htaccess or php) to push folks along to the new locations of articles (which might be, or, whatever).

    2. A BIG piece of this is ‘transferring’ pagerank properly with Google. I’m happy (and intend…) to set up a Google Sitemap (plugin or otherwise) on to help future scrapes, but want to use proper redirects so Google has a clue what’s going on.

    (And if anyone knows whether ‘splitting’ articles between the two sites might confuse Google, that’d be good to know… and might change my strategy/approach if needed…)

    Thanks again,


    Google will recognize a 301 Permanent Redirect, and should (eventually) adjust pagerank of the destination site accordingly.

    As far as what approach to use, it probably depends on how flexible you need to be. If you can easily map the old URLs to the new ones with a regex, then putting the rules in .htaccess should be just fine. If there are funky exceptions to some of the rules that require a little more logic, then handle it in your index.php or maybe in a custom 404 handler.

    Personally, I’d probably do it in a 404 handler (make sure that you set the HTTP 301 redirect headers in your code!), unless you have overlapping URIs that need to exist on both sites. You can see how I handled this on my site. (ignore my brutish methods of parsing the request URI — I don’t know why I didn’t use PHP’s parse_url() and parse_string() functions.)

    Yeah. I’m trying to figure out if I can do it with one 301 at (which would likely require it all be in PHP), or do it as a ‘split’ 301 based on the post ID in htaccess at and then PHP to get to nice-URI final.

    I assume I can do a regex with say a dozen post IDs to match that go to a subdir on, and all others redirect to, and THEN use one of the ‘single URI per resource’ plugins to 301 AGAIN to the actual ‘final’ nice-URI link (since I’m considering moving to a /%postname%/ URI… though given the complexity I might be better off with a /%postid%/ URI, as I’m sure there’s a match-arg in mod_rewrite to grab p=### and transform it into /arc/post###/ or equiv…).

    Thanks for the ideas. I’m letting it percolate a bit. 😉


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change domain AND permalinks in one redirect?’ is closed to new replies.