Managing files when moving to multi-site in Drupal 6

One thing I have been doing quite a lot recently on clients sites is merging multiple Drupal 6 installations into a multi-site setup. This is usually quite painless and can be done within an hour or so, the hard bit comes when none of the display, and you realise that all of the paths in the files table are still set to "sites/default/files" when they should be "sites/example.com/files". Well, there is a quick solution to this.

  1. Connect to the database, the easiest way to do this is using the "drush sqlc" command.
  2. Run the query "update files set filepath = replace(filepath,'sites/default/files','sites/example.com/files');"
  3. Reload the site in your browser and marvel at the beautiful images.

It's as easy as that, unless, some of the file paths have been hardcoded into nodes and blocks, but this can be resolved using the same method on the node_revisions and boxes tables.

Similar posts

Mailing list

Subscribe for monthly updates, blog posts, and client case studies direct to your inbox.

Twitter