Move a Drupal Site to a New Folder

media_1367945960909.png

Moving a Drupal site to a new location on your server is surprisingly easy.

There is a simple 3 step process to move a Drupal site from one folder to another. In this tutorial we’re going to show you those 3 steps.

If you’d like to move a Drupal site to new folder, we recommend using the Backup and Migrate module.

Step #1: Move the files

The first step in the process is to move your site files to their new location.

Browse to your Drupal site on your server and you see will see a files and directories like these below.

There are two different approaches you can take:

  1. Rename your older with the site inside. In this example, I’m going to take the current folder which is /old/ and rename it to /new/.
  2. Select the files and folders. Drag-and-drop them to their new location This would work best if you wanted to move your Drupal site from a sub-folder to your main directory.
media_1367945960909.png

Step #2: Edit settings.php

Now that your site is in it’s new location, you’ll be able to see your site. It may look perfectly OK, but the links to inside pages are unlikely to work. Click on any links and you’ll get “Not Found” errors.

media_1367946240834.png

To fix the links on your site you need to edit your settings.php file.

The settings.php file is the most important file on your Drupal site. Click here for complete overview of settings.php.

To find the settings.php file, look inside the /sites/default/ folder.

media_1367946386420.png

Open the settings.php file.

You are looking for the lines around 229 to 249 that deal with your site’s Base URL. You need to change the last line in this section to reflect your site’s new location. In this example, I’m going to change /old/ to /new/.

Save the file.

media_1367946521896.png

Step #3. Test your site

Hopefully your site has been successfully moved.

Test all your links to make sure nothing is still broken. Also, browse the site to make sure you didn’t miss any files and folders during Step 1.

Author

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Article Rating
Subscribe
Notify of
5 Comments
Oldest
Newest
Inline Feedbacks
View all comments
anon
anon
10 years ago

cache should be cleared and if using a wysiwyg editor (they use absolute urls) one will have to perform a search replace on the database.

Rolando
Rolando
9 years ago

hi, thanks for the explanation, but what about the data base? the data base file still with the old path would be neccesary to change it too?
i want to be very sure before make this change

thanks

steve
steve
9 years ago
Reply to  Rolando

No, there should be no need. t
The database information is inside settings.php and doesn’t need a path.

shruti
shruti
8 years ago

i have copied all files into new folder but user login page is not displaying i am getting 404 error.

Please advice what shud i do?

Royce Barber
Royce Barber
6 years ago

Thanks for a lovely article. I’m using GoDaddy’s unlimited websites hosting via cpanel in linx. I used Instalatron to install Drupal8 to my root folder. Many months later, I realized I should have installed Drupal8 to a subfolder instead. Because it’s blocking the install of any other website system. I had to disable Drupal8’s HTAccess file to install DokuWiki or anything else. I’d like all sites to be in subfolders. So I used installatron to clone my Drupal8 site into a subfolder. But the cloned site won’t run, with the root site’s HTAccess file disabled or not. Many sites say something in settings.php needs to be set, but it’s worded differently than in your article. My Drupal8 settings.php says the following;

# $settings[‘file_public_base_url’] = ‘[url=http://downloads.example.com/files’;]http://downloads.example.co…[/url]
And the cloned drupal8 site I’m trying to get working is called [url=http://www.ontu.org/x]www.ontu.org/x[/url]
Any ideas? Thank you kindly.

5
0
Would love your thoughts, please comment.x
()
x