Closed (fixed)
Project:
FileField
Version:
6.x-3.0-rc1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
15 Apr 2009 at 15:55 UTC
Updated:
28 Sep 2009 at 13:32 UTC
There appears to be a problem when moving a site from one domain to another that causes the URLs to break. Details below.
Comments
Comment #1
Mac Clemmens commentedI'm getting an error when I move my drupal installation from one domain to another. Even if I update my files path in the system, I get URLs like this:
I'm sure I'm more complicated than most, as I like to stage sites at a subdomain (and possibly at a subdomain of another domain) prior to making them live. If I manually remove sites/olddomain.org/files/ from the URL, it works. But I thought it should be resolved, as this first came up when the beta was released and still affects some sites even in RC1. All my linked files broke. Had to noodle around in SQL to fix it.
My file path is /sites/newdomain.org/files (entered at /admin/settings/file-system)
It may be worth noting that if I edit the node and click Save that the problem goes away. But if I switch back to the other domain (using the same database) and edit and save it there, it breaks on the live site. (and vice versa)
Any tips?
Comment #2
quicksketchIt's not a bug in FileField. This is the way core handles files unfortunately. You CAN'T change the file system path (ever), unless you do manual SQL updates to fix the existing files.
#324474: migrating servers issue
#427126: Moved servers, now incorrect paths
The best solution to this (as dopry mentioned in those issues), is to never use the name of the domain in your file system path. Instead make a symlink that uses a generic name.
On your dev server:
On your live server:
Then set your file system path to
sites/example/files.Comment #3
quicksketchComment #5
Mac Clemmens commentedThank you - this is a great tip!
If anyone else has run into this issue like I have where you need to change the file upload path after you've already uploaded a bunch of files, you can use the following SQL commands to update the `files` table in your database:
Substitute sites/incorrectpath.org/files/ with the path you are using, and this SQL command will strip it out from the beginning of all the filepaths.
UPDATE `files` set filepath = SUBSTRING_INDEX(filepath, 'sites/[incorrectpath.org]/files/', -1);
Then you can run this SQL command to prepend the correct path at the front again, hopefully fixing the problem.
UPDATE `files` set filepath = CONCAT('sites/[correctpath.org]/files/', filepath);
Remember to BACK UP YOUR DATABASE before executing this code. It could eat your babies!
Comment #6
epg commentedI have the same problem, except I'm on a windows server on my local machine. How do I fix this (a solution equivalent to the one in comment #2)?
I do not want to have to go and manually alter the database every time I upload changes from my local machine to my live server.
My live server is on bluehost. How do I implement the solution in comment#2 on bluehost?
(keep in mind I'm a complete newbie!)
Thanks!
Comment #7
quicksketchepg, let's keep your questions to one issue, since I'm also answering you in #409884: a way to refresh filepaths stored in database?.