mysql

Image links When Moving Drupal to Multisite - Find & Replace in Mysql

Since the release of Aegir 0.3 I've been using Drupals multisite configuration like crazy.  Mainly because Aegir uses it but also because it just makes sense.  Starting a site in multisite works great, but moving an existing site to multisite configuration can cause some problems.

For example, on a regular Drupal install the images and file uploads are stored in the "sites/default/files" directory.  On a multisite install, the files/images are stored in "sites/example.com/files" directory.  This causes a problem becuase the links to most images/files that are in content will point to the wrong location:

  • Links will look like: http://example.com/sites/default/files/myimage.jpg
  • Instead of: http://example.com/sites/example.com/files/myimage.jpg