Jan 19 2009

WordPress: Hacking Subdomains

Published by Kenneth Newquist at 9:46 am under Technology, Web Applications, WordPress and tagged:




By default, WordPress Mu wants to serve sites in one of two ways: using a “folder” methodology (e.g. wordpress.foo.edu/[site name]) or subdomains (e.g.  [site name].blogs.foo.edu). The problem is that out of the box, the subdomain approach wants you to rely on wildcard DNS entries to send traffic to WordPress.

This works fine if you’re serving up something like blogs.foo.edu, in which you expect each blog to be part of a larger subdomain, but it’s problematic when you want to serve sites one step up the food chain (e.g. [site name].foo.edu). (if for no other reason than all the extra MySQL work that gets created as WordPress tries to resolve traffic to non-existent subdomains).

Ideally, I want an admin blog account installed at something like wordpress.foo.edu, but then subdomains for every thing else.

Out of the box, WordPress doesn’t want to work like this (since it wants all of its subdomains to appear off of wordpress.foo.edu, rather than foo.edu). Fortunately, you can tweak the Mu database to get around the limitation.

  1. Install WordPress Mu with subdomain support to wordpress.foo.edu
  2. Configure the admin blog.
  3. In MySQL, change the “wp_site” table, changing the route domain (in the “domain” column” to “foo.edu” from “wordpress.foo.edu”
  4. Create a C name in DNS for the subdomain you want to serve (e.g. bar. foo.edu) that points to wordpress.foo.edu)
My network services colleagues and I experimented with this on Friday, and it worked well. We won’t be using it for the upcoming WordPress Mu pilot (which will be hosted on its own subdomain) but likely will if we go into production with the platform.

No responses yet


Create a free edublog to get your own comment avatar (and more!)

Comments RSS

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image