How To Enable Subfolders for WordPress Hive

Wordpress Hive

by Jon on March 24, 2010

in Web Development

I was going to post this over at the WP Hive forums but their forum registration doesn’t seem to work so I’ll just put it here.

WordPress hive is a super useful plugin that lets you install one copy of WordPress and run a bunch of different sites on it. Quite useful for the enterprising web developer. It does however have some limitations one of which is that since all your sites are pointed to the same place if you want subfolders to hold files or images or whatever that subfolder would be accessible from all the sites run off of the hive installation. Not something you want obviously.

So I figured out a way around this and thought I’d share. To do this you’re going to need shell access to your server probably unless you can talk your admins into doing it for you but it could be a bit of a pain.

Anyway typically you’d install the site into the WordPress Hive plugin using their directions and to get it to work you’d “point” that domain to the domain running the hive. Basically this amounts to adding the domain as an addon domain in your cPanel then making the folder that would hold the domain files into a symlink pointing at the folder holding the hive installation.

Now if you want to enable subfolders for this new site, say you want to host a file people could download or something, what you’re going to do is instead of making that folder be a symlink you’ll create that folder. Then you’re going to go in there and make a symlink to each file in the hive installations folder with the same name. Pretty simple but can take a bit of time. You may want to write a script to do it as well, I haven’t yet but probably will as you’ll also have to keep these symlinks up to date when you upgrade WordPress. Another trick is to make a folder that holds all these symlinks (using absolute file names or relative to your home directory)  and just copy it over whenever you want a new site with subfolders enabled. Also keep in mind that if you’re looking at this folder in your FTP client it’s going to look like all those files are there instead of just symlinks so be careful that you know what is what if you go messing around with FTPing things around. Oh and always remember to back up stuff before you go messing around you know how unforgiving Unix is.

Now viola you’ve got subfolders. Now you can put whatever you want in that folder along with the symlinks and serve up other files. For instance you could have a subfolder with another WordPress install in it or another piece of software in that folder.

Sweet huh? Now get back to work! :D

UPDATE: I’ve coded up that script to keep the symlinks up to date and made a new post about how to how to keep your custom WordPress hive installation up to date.

Photo Attribution

Be a Social Geek:
  • Facebook
  • Twitter
  • Reddit
  • Digg
  • StumbleUpon
  • del.icio.us
  • Slashdot
  • Fark
  • Technorati
  • Sphinn

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

{ 1 trackback }

Previous post:

Next post: