Move Moodle from subdomain to folder

Move Moodle from subdomain to folder

by Annie Minton -
Number of replies: 3

I need to move a Moodle 3 site which is still in development, from a subdomain to a folder within the public_html, on the same server.

The subdomain is above the public_html, as is the moodledata directory.

I have read a couple of forum threads and moodle docs, eg: https://docs.moodle.org/32/en/Moodle_migration#Copy_the_Moodle_code_from_the_old_server_to_the_new_server, but nothing deals specifically with moving from a sub domain to a folder. I also don't know how the cron will be affected and basically I'm concerned that I don't have the technical knowledge to do the move myself. If I run into difficulties I don't have spare hours of time to spend troubleshooting it without assistance.

I do not have shell access and would not know how to use it if I did.

I'm hoping someone will be able to offer step by step advice for this scenario.

Average of ratings: -
In reply to Annie Minton

Re: Move Moodle from subdomain to folder

by Jamie Kramer -

Here is a top level overview. I'll start with these example assumptions.

  • Server account name is acmeinc
  • Home directory is /home/acmeinc
  • Subdomain where moodle is running is moodle.example.com
    • Path to web root for Moodle site is: /home/acmeinc/moodlecode
    • Path to data directory (defined as dataroot in config.php) is at /home/acmeinc/moodledata
  • Primary Domain where you want to move moodle as a sub-folder: www.example.com
    • Path to web root for primary domain is: /home/acmeinc/public_html
  • The assumption is that you want to move the Moodle site moodle.example.com

Using the control panel of your hosting provider account, you would:

  1. Back up the Moodle database (as defined in config.php) using the database backup utility of your hosting provider
  2. Copy the /home/acmeinc/moodlecode folder to /home/acmeinc/public_html/moodle
  3. Edit the /home/acmeinc/public_html/moodle/config.php file
    1. Change wwwroot setting from http://moodle.example.com to http://www.example.com/moodle
  4. Access the site at: (http or https?)... http://www.example.com/moodle   and see if the site seems to be working, then
    1. log in as admin
    2. purge caches
  5. If the site is not working, something has gone wrong and need to go back and check steps
  6. While logged in, if the site seems to be working, then use the admin replace tool (and this step is why I strongly urge to have a db backup first)
    1. https://docs.moodle.org/33/en/Moodle_migration#Update_links_containing_wwwroot_in_the_databse
    2.  (you may need to adjust depending on whether you are using http or https)
    3. Search for old URL: http://moodle.example.com
    4. Replace with new URL: http://www.example.com/moodle
    5. Purge caches again for good measure

I hope that helps a little bit.

Average of ratings: Useful (1)