Migrating the Blog to OpenShift

So this weekend I migrated the blog to Red Hat’s awesome new OpenShift service. If you are reading this, it means the migration was successful! Overall it went fairly smoothly. I’ve migrated my install multiple times at this point, so I was familiar with the process. But I also found that Deon Garrett has written some great documentation.

One of the problems identified by Deon is the inability to CNAME the root of the domain. Basically he uses a common domain provider’s URL Forwarding feature to redirect example.com to www.example.com. This workaround is great for a typical WordPress install. But for a subdomain-style, multisite installation, you have a problem where his forwarding approach results in an infinite redirect loop.

The key is that in a subdomain-style multisite installation, WordPress redirects www.example.com back to example.com. In order to fix this, we need to trick WordPress into thinking that www.example.com is, in fact, example.com. You can do this simply by adding a single line to your .htaccess file:

RequestHeader edit Host “^www\.(.*)$” “$1”

This line strips ‘www.’ from the start of every Host header. This works in my installation, but you might need something a bit more specific for your installation. For additional options, see mod_headers.

If you have interest in deploying WordPress on OpenShift, you should note that I have provided pull requests for updating OpenShift’s WordPress to 3.5.1 (the latest) and for enabling multisite WordPress uploads.

Happy OpenShifting!

3 thoughts on “Migrating the Blog to OpenShift

  1. I’ve migrated my own blog a few weeks ago but I jused a “blog.” subdomain. And I didn’t care much about the blog url redirect so I just updated feedburner feeds and left a message at the old blog about migration for those that used direct RSS feeds instead of feedburner. I am lazy dog…

  2. Your site seems to be using a *.rhcloud.com cert? This gives me a mismatch here.

    Is this just because you don’t have a custom cert for it, or is there some issue still with the config?

Leave a Reply

Your email address will not be published. Required fields are marked *