In a nutshell, I am moving (in a Drupal multisite installation) the sub-directory myfirstsite.com.mysecondsite to its own domain, mysecondsite.com. Detailed info of the site and what I did are below, but a summary of the problem is that nodes with images still contain links to the old image location and so do not show up, and I do not understand why this is happening. Now, here's the detailed info:

Site info
I'm running a multi-site installation of Drupal 6 with the main installation at:
public_html/drupal (or myfirstsite.com/drupal)

I set up another site as a sub-directory, like:
public_html/drupal/sites/myfirstsite.com.mysecondsite

I'm using CKE editor with IMCE as file uploader. Images are stored in:
public_html/drupal/sites/myfirstsite.com.mysecondsite/files/myfirstsite.com-admin

Drupal apparently created the subdirectory:
public_html/mysecondsite

and it contains directories, like:
cgi-bin
includes
modules
profiles
scripts
sites
-----myfirstsite.com.mysecondsite
----------files
---------------myfirstsite.com-admin
themes
tmp

The directory:
public_html/mysecondsite/sites/myfirstsite.com.mysecondsite

is apparently a mirror of:
public_html/drupal/sites/myfirstsite.com.mysecondsite

Now, to the question
I am moving myfirstsite.com.mysecondsite to its own domain, mysecondsite.com. Here's what I did:

Registered the domain, mysecondsite.com and, via cPanel, added it on to myfirstsite.com
Created the folder, public_html/drupal/sites/mysecondsite.com
-----Created the folder, files, within that
Created a new db for mysecondsite.com
Exported the db for myfirstsite.com.mysecondsite
Exported the files table for this db with droptables attribute
Exported the node_revisions table for this db with droptables attribute
Did search and replace on files and node_revisions tables
-----replaced all instances of drupal/sites/myfirstsite.com.mysecondsite/files/*
----------with drupal/sites/mysecondsite.com/files/*
-----replaced all instances of /mysecondsite/sites/myfirstsite.com.mysecondsite/files/*
----------with /sites/mysecondsite.com/files/*
Imported the myfirstsite.com.mysecondsite database into the mysecondsite.com database
Imported the modified files and node_revisions tables
Copied the images to new location
Emptied the cache tables in the mysecondsite.com database

I can access the new site at mysecondsite.com, and all appears well, except for images, which do not appear. Looking at the page source, I see that, in spite of my search and replace, the images still contain links to the old location and not the new location. It is apparently not a browser issue, since I cleared caches in FF and Chrome to no avail. Also, I used another machine that had never accessed this site with the same result.

What little I already know tells me that this has to be a cache issue, but I do not know what else to do, so I hope that someone can help.

Thanks.

Comments

ayesh’s picture

If Drupal itself added a link, it's always a relative link. So you can move domains indefinitely without any problem.
But, for images, if you added URLs with "http://myfirstsite.com" domain, unfortunately there's no pretty way to fix it.

Edit a node with plain-text editor(disable CKeditor, etc) and see how images are linked. If those are absolute URLs, you may need to do one of following.
1. Manually change URLs of each node.
2. Run a huge find-and-replace like queries through mysql
3. Create .htaccess redirects to find the new domain(an easy way but won't work for all use-cases)
4. Or wait someone with better knowledge to give an answer.

jfmoore’s picture

Thanks, Ayesh. Here are what the links look like:

<img src="http://myfirstsite.com/site/uploads/img49569949 />

Not sure what did the above link, but ones like this are few.

<img src="/mysecondsite/sites/myfirstsite.com.mysecondsite/files/myfirstsite.com-admin/imagename.jpg" />

Pretty sure the above link was done by IMCE. This one is relative to public_html, and would, I imagine, have to be changed (by Drupal, or whatever) to:

<img src="/drupal/sites/mysecondsite.com/files/myfirstsite.com-admin/imagename.jpg" />

Anyway, I did a search and replace on the files and node_revisions tables and then re-uploaded them, but the old links are still appearing in the node source. My main problem, I guess, is that I don't know how this is supposed to work.

Is there a particular way to make this change:
from drupal/sites/myfirstsite.com.mysecondsite to drupal/sites/mysecondsite.com

that would prevent problems like I am experiencing? I read somewhere, for example that one person just changed the name of the directory, for example, from:
drupal/sites/myfirstsite.com.mysecondsite

to:
drupal/sites/mysecondsite.com

Of course, I don't know what he did about the sub-directory, public_html/mysecondsite that Drupal created, and that brings to mind a few questions about this: Why is this sub-directory created, and how is it used? Is it a copy of:
/drupal/sites/myfirstsite.com.mysecondsite

In setting up the sub-directory, drupal/myfirstsite.com.mysecondsite, I had to make a symlink like:
ln -s drupal mysecondsite

Is that what created the sub-directory, public_html/mysecondsite? And, if so, if I remove the symlink, will it go away?

Any light you can shed will be appreciated. I would like to understand this process better.

ayesh’s picture

Symlinks!
Yes, it's the best way to fix this problem. But you must own both domains and should be in same server.
Symlinks will do that, giving new folder structure when the older one is requested.

For MySQL find-and-replace, see http://www.mediacollege.com/computer/database/mysql/find-replace.html