I want to move my blog from its original domain (site1.com) to become a sub-domain on another domain which is a multisite installation (sub1.site2.com).

I also want to change the permalink structure on the new site based on some SEO suggestions I read online. Original used /%year%/%monthnum%/%category%/%postname%/ as its permalink structure. I want to switch to posts/%category%/%postname%/as the new permalink structure on sub1.site2.com . I am changing the permalinks because I rightfully agree with some SEO suggestions that articles may feel dated if the year is prominent in the URL when actually the content is mostly not time dependent.

How do I use either .htaccess or a plugin or even PHP (as in this thread) to ensure links from the old site (posts, category and other archives) do not break especially because of the the change in permalink structure.

I tried following a few previously answered questions but got confused becasue of the nature of their specific queries. Also Regex syntax is relatively new to me so I want to defer to people who know what they are doing fully.

1 Answer 1


You can do the redirection in one step or in two steps. The one step solution redirect all traffic directly to the correct URL on the new server, the two step solution simply redirects all traffic to the same path on the new server, and let the new server figure out the correct path after that. I don't know whether there is a SEO penalty with two redirects, maybe you should ask this on the related Pro Webmasters Stack Exchange site.

Redirect in two steps

In two steps is probably the easiest to set up: you redirect all traffic to site1.com/some/path to sub1.site2.com/some/path, and let the second site figure out the correct destination, for example with the Redirection plugin.

You can configure the first redirect in Apache, with a simple Redirect rule in your server configuration (.htaccess, or httpd.conf or related):

Redirect 301 / http://sub1.site2.com/

You could also do this in PHP, but for such a simple redirection it would be overkill.

Redirect in one step

If you want to redirect in one step your old server should know the new location of all URLs. For your posts this seems to be easy (only the date is stripped?), but what about the category and archive pages? Anyway, you can also do this in Apache with a RedirectMatch rule and a simple regular expression. Basically you want to match all URLs that start with a year and a month and then some stuff, and redirect them to the new site + some stuff. \d means "a digit", {4} means "repeated 4 times", . means "any character", and + means "repeated one or more times". The () "collect" the match, so we can use it in the replacement (as $1).

RedirectMatch 301 /\d{4}/\d{2}/(.+) http://sub1.site2.com/posts/$1

You can combine both rules, so posts get redirected in one step and everything else in two steps. The first rule that matches is executed, so place the regex rule on top.

  • Thanks Jan. I am heading to Pro Webmasters to find out if there is an SEO penalty fo rthe two step redirect but I think I may implement this using both rules as you suggested finally.
    – Nana Kwabena Owusu
    Nov 6, 2010 at 11:28
  • For reference: the related Pro Webmasters question is SEO: Will Multiple Redirects (301, Permalink Plugin) affect ranking
    – Jan Fabry
    Nov 6, 2010 at 13:41
  • Thanks for adding the reference to the Pro Webmasters thread. I'm still learning the ropes using StackExchange.
    – Nana Kwabena Owusu
    Nov 7, 2010 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.