Moving your Drupal installation to a new directory
If for instance you need to move your installation from www.mysite.com/development/ to the root directory of www.mysite.com, just follow these simple steps:
- Copy Files
-
Copy the files of your Drupal installation from the old directory to your new directory. Make sure you include .htaccess.
- Change Path
-
In your new directory, open the file (4.5 or earlier) includes/conf.php or (4.6) sites/default/settings.php
Look for a line that begins with "$base_url = ", update this so that $base_url equals the path to your new directory. Save the file and close it.
You might need to modify the .htaccess file as well.
- Update Cron
-
If you set up Cron on your old installation, make sure you update it to point to your new installation.
- Delete Old Directory
-
Test that everything is working in your new installation. If so, it is now safe to delete the files in your old Drupal directory.

Two more items
In addition to the steps listed above, I had to do the following two items so that my site appeared correctly after I moved it (drupal 5.3):
Another problem - Internal Links...
In a traditional HTML site, use of 'relative' links allows you to move the entire site to a new directory or even a new domain without breaking 'internal links'. However, for many Drupal sites, relative links are not very meaningful because the URL paths do not correspond to physical directory structure, as in HTML sites.
Thus, links coded within a node to a URL on the same site (internal link) will usually use an 'absolute' path (full URL) or a 'server relative' path (relative to server root e.g., /some/path) - in either case, the link will be broken when you move your site to a new directory. This DOES NOT apply to links generated by Drupal (e.g., menus, taxonomy terms, etc.) - only to internal links that have been 'hard coded' into, e.g., the body of a node.
AFAIK, there is nothing to do about this - just be aware of the problem so you can correct any internal links after moving your site.
There's more to consider if moving a Drupal installation
I followed these instructions and moved a Drupal 5.7 installation from /oldpath to /:
* copied the files from /oldpath/* to /*, including .htaccess;
* edited .htacces and changed all references to /oldpath;
* edited Apache's configuration for the vhost, restarted httpd;
* edited sites/default/settings.php and changed all references to /oldpath;
* ran crontab -e and changed all references to /oldpath;
The result: accessing the site at the new location results in a WSOD (blank page in browser), accessing /node results in a WSOD, also. Accessing /admin is possible, however I can't log in by entering my credentials at /user (access denied); however, entering them at /?q=user works. Apache's error log reports nothing but "File does not exist"; /update.php is accessible and working. In this instructions some crucial steps seem to be missing - the site is dead.
Other steps that might be necessary:
* Login without blocks and menu - /?q=user
* Disable Clean URLs - /?q=admin/settings/clean-urls (http://drupal.org/node/5590)
* Disable Drupal caching - /?q=admin/settings/performance
* Clear the Views cache (if using views) - /?q=admin/build/views/tools
* Repair absolute or relative system paths for contributed modules that rely on 3rd party software residing somethere else in your system
* Check the contents of the "systems" table in MySQL
There's definitely more to consider if moving a Drupal installation than these simple steps!
* Do a fresh setup at something like test.example.com, check if everything works, use the working configuration files from the "test" setup and adapt them for www.mysite.com/oldpath/
* Overwrite the moved setup with a fresh installation (save .htaccess and sites/default/settings.php to a secure place, and have your database credentials ready); the installer will recognize an existing database and should create a fresh configuration.
In my case, nothing of this worked. Even /?q=admin became inaccessible at some point. It was NOT possible to get the moved Drupal installation running from www.mysite.com/ instead of www.mysite.com/oldpath/. So be prepared to UNDO all the steps described before when falling back to /oldpath. So BE PRPARED FOR TROUBLE!
With lots of digging, I discovered the problem: A contributed filter (PEAR_Wiki_Filter) had a path that was pointing to the old location. I discovered this by diasbling ALL contributed modules: If thes reside in ../modules, move all of them to something like ../modules_inactive, then moven them back one by one until the site dies. DO NOT disable Drupal's core modules when doing this!
If you should succeed to move your Drupal site from a subdirectory to the server root, all search engine paths will run empty. On http://drupal.org/node/144643, there are some notes on Rewrite rules that can fetch those old paths (stripping /oldpath from the URL) and make them work again. In my case, I wanted everything pointing to /olddir to remain ransparently accessible. One simple rule in .htaccess did the job:
RewriteRule ^olddir/(.*)$ /$1 [R=301,NC,L]This catches every request to /olddir and rewrites it to the server root.
There are some discussions on moving a Drupal site, e.g.
* Move drupal site to another location?, http://drupal.org/node/140714
* Moving Drupal from subdirectory to directory, http://drupal.org/node/20853
Alos, there might be alternative ways, e.g.:
* Drupal installed in subdirectory but made to appear in root, http://drupal.org/node/144643
Good luck & Regards, asb
Thanks!
Worked perfectly except for the .htaccess rewrite rule to redirect old links from search engines. This worked for me instead:
RewriteRule ^/?olddir/(.*) http://site.com/$1 [R=301,L]I also had to put this directly under:
<IfModule mod_rewrite.c>RewriteEngine on
which was on my line 66 of my root .htaccess. Thanks a ton!
P.S. http://validator.w3.org/checklink is also useful to check for broken links