Although so many articles have been written about this issue already, the approach I'm using successfully hasn't been mentioned yet - or I missed the appropriate post. Hence I'm writing another one and hope people may find this useful.
What's the issue?
When developing a website for on a server with a URL/domain which most likely is different from the URL/domain of the live site later on, you will run into trouble when migrating from development to live because of some files and links in nodes and elsewhere being addressed in a location which by default contains the domain name in the path and therefore will be broken after .
How to setup environment to avoid this issue early?
First of all, follow the standard instructions for setting up your new site on the server. In particular, create the directory
DRUPAL_ROOT/sites/dev.example.com and inside this directory the file
settings.php. All the settings inside this file should be standard, so no difference to any other site you would be setting up for .
In this example we are developing on
http://dev.example.com and to install your site you should next call
http://dev.example.com/install.php and follow the instructions.
When done your site is ready. Now, hold on! Before you do anything else you should now change one of the default settings to be ready for later :
Let's assume the site will move to http://www.mycustomer.com later on, please follow these steps:
- Create the directory
DRUPAL_ROOT/sites/www.mycustomer.com/fileson your server
- Go to
http://dev.example.com/admin/settings/file-systemand change the setting in the first field file system path from
sites/www.mycustomer.com/filesand save the configuration
Now you're done. You can develop without any problem and once you migrate to the live site, you don't need to change any values or even database content. It's just done.