MCNi Wiki : Updating old band site URLs

All new Bombplates sites have a canonical url along the lines of someband.bombplates.com. However, the earliest sites did not do this; we let the band pick their own canonical url (e.g. someband.com).

99% of functionality works like this. The one exception is that old sites can't change their theme. They will get an error saying "There is a critical error in your site configuration! Please contact support." Should this happen, the user will have to contact us, wherein we will update their site.

For our instructions, we'll be moving a band called somebandmusic.com to someband.bombplates.com (for early sites, the subdomain is always the first 8 characters of their selected domain)

Log into bands2.bombplates.com
$ cd /var/www/html/sites
$ mv www.somebandmusic.com someband.bombplates.com
$ sudo vim /etc/httpd/conf.d/bombplates.conf

Remove the old entries for someband.bombplates.com and www.someband.com

Add

<VirtualHost *:80>
  ServerAdmin info@somebandmusic.com
  DocumentRoot /var/www/html
  ServerName someband.bombplates.com
</VirtualHost>
<VirtualHost *:80>
  ServerName www.somebandmusic.com
  ServerAlias somebandmusic.com
  RewriteEngine On
  RewriteOptions inherit
  ProxyRequests Off
  ProxyPreserveHost Off
  ProxyPass / http://someband.bombplates.com/
  ProxyPassReverse / http://someband.bombplates.com/
  ProxyPassReverseCookieDomain .bombplates.com www.somebandmusic.com
</VirtualHost>

Restart httpd

# /etc/init.d/httpd restart

Update the HOSTS file

# vim /etc/hosts
127.0.0.1 someband.bombplates.com

Log into the someband.bombplates.com/user

go to someband.bombplates.com/admin/settings/file-system

Update the file system path to sites/someband.bombplates.com/files

Go to someband.bombplates.com/admin/build/themes

Find LiveSite; set it to active and default; submit the form.

Update the file paths in the database

Get DB credentials from sites/someband.bombplates.com/manual_db.php

$ echo 'SELECT fid, filepath FROM files;' > ~/tmp/dump-files.sql
$ mysql -u someband_user -pPASSWORD someband_db < ~/tmp/dump-files.sql > ~/tmp/someband.files.sql
$ vi ~/tmp/someband.files.sql
   :%s/\([0-9]\+\)\ssites.www.someband.com.\(.*\)/UPDATE files SET filepath="sites\/someband.bombplates.com\/\2" WHERE fid=\1;
$ mysqldump --add-drop-table -u someband_user -pPASSWORD someband_db >  ~/tmp/someband.backup.sql
$ mysql -u someband_user -pPASSWORD someband_db <  ~/tmp/someband.files.sql

Flush the cache

Alert the user that their site is fixed