How to change your URL in Moodle Updated on August 16, 2021 by InMotion Hosting Contributor 2 Minutes, 11 Seconds to Read When you are running a Moodle website, there may be times when you have to change your URL. For example, you may have sold the website, or maybe you purchased a shorter domain name, and want to replace the old one. In this tutorial we will show you how to change your URL in Moodle. We are going to use the replace script, that is included with Moodle. It essentially searches the database for the old URL, and replaces it with the new one. After changing your URL in Moodle, you may still need to move the files to a new location, based on your setup. Note: Any time you are modifying a database, we recommend performing a backup first. Get Started with Moodle on a Dedicated Hosting server today! Changing your Moodle URL Login to the Moodle Dashboard.Add /admin/tool/replace/index.php to the end of the URL, and hit Enter on your keyboard. The address will look like this:https://example.com/admin/tool/replace/index.php(Be sure to replace example.com with your Moodle site. With older versions of Moodle add /admin/replace.php to the end of the URL.) You will then be on the DB search and replace page. It will look like this: You will also see a message stating “This script is not supported, always make complete backup before proceeding! This operation can not be reverted! Several tables are not updated as part of the text replacement. This include configuration, log, events, and session tables.“ In the Search whole database for field, enter your existing URL. in my test I entered: https://example.com In the Replace with this string field, enter the new URL. In my test I entered: https://newdomain.example.com Check the box for Shorten result if necessary. Confirm the change, by checking the box for I understand the risks of this operation, then click the Yes, do it! button. It is finished when you see a message stating “…finished” at the bottom. Click the Continue button to return to the Moodle dashboard. Using FTP or File Manager, navigate to where Moodle is installed. Open the config.php file, and locate the line starting with:$CFG->wwwroot Update the line to your new address, in my test I changed from this: $CFG->wwwroot = 'https://example.com'; To this: $CFG->wwwroot = 'https://newdomain.example.com'; Here is a screenshot of the updated line: Save your changes and you are done. Now you can move your site (if necessary) to the new folder location. Congratulations, now you know how to change your URL in Moodle! Share this Article IC InMotion Hosting Contributor Content Writer InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals! More Articles by InMotion Hosting Related Articles How to install Moodle using Fantastico Installing Moodle with Softaculous How to Add Content Security Policy in Moodle With the Local CSP Plugin Inserting an image slider in Moodle Changing the Moodle admin password through PhpMyAdmin Fix “uploaded file may exceed the post_max_size directive in php.ini” How to Add the Quiz Module in Moodle Adding the File Resource Module to Moodle Courses Integrate Jitsi with Moodle Courses How to Install a Plugin in Moodle
Hello all, I’m new to Moodle cloud and I have setup and created user account and working fine, I don’t know how to allow them to uploade file in their login and also how other teacher can download, please assist me . thanks, God bless
Here is a helpful guide on using assignments in Moodle, it includes a section on “File Submissions” that goes over the steps for students to follow to upload a file. Thank you, John-Paul
Hello. Thanks for posting your comment regarding reverting the changes. We recommend using a backup (made prior to making database changes) to restore/revert these kinds of changes. I hope this helps! Sincerely, Carlos D.
Moodle Cloud is a hosting platform for Moodle as opposed to self-hosting, where you can edit core files. I suggest contacting Moodle Cloud support to see if they can help you change your URL.
My Moodle domain already expired – I can not access moodle through domain name. Please suggest what to do.
John, if you have website hosting with us, you can use your ‘temporary’ URL to access your website. Otherwise, I would recommend using a host file modification.
Hi, I have one question, hopefully someone can help me.. Scenario:In my office we have 2 connection wifi..1 for staff & 1 for student.After i change the url, from staff wifi & using personal mobile data can access Moodle but from student wifi site cannot access.. I dont know the issues come from moodle itself @ i need to look into our network configure..Anybody can help me? Thanks you so much..
Hello Leen, Sorry for the problem with accessing your Moodle site. This type of issue would best be answered in the Moodle support forums. Check out this post. The issue may have to do with security settings in Moodle. If you have any further questions or comments, please let us know. Regards, Arnel C.
Hello Said, Sorry for the problem in your opening your domain. We would need more information in order to give you assistance. We would need the name of the domain and the exact steps you’re doing that lead to the error. If you have any further questions or comments, please let us know. Regards, Arnel C.
Thanks for this lesson.I implemented it but I got stucked. I cannot open my moodle site again. What i guess is missing is,I may need to move one file to another location after changing the subdomin. Please how do i do that. A solution is urgently needed.Thank you.
Hello Victor, Sorry for the problem with your Moodle installation. If you need to move a file, you can use the cPanel File Manager or an FTP client. If you have any further questions or comments, please let us know. Regards, Arnel C.
Just wanted to note, in my case I also had to change this line in the config.php file: $CFG->dataroot = ‘example.com’;
Hello Andy, Thank you for your question. When you run a query, depending n on your website, it can return a massive list of results. The Shorten result if necessary option, makes the list less extensive. For example, if 2,000 lines of code were modified, it would shorten the results. It does not affect the functionality of your query. Unfortunately, I do not know the exact cut-off criteria. If you have any further questions, feel free to post them below. Thank you, -John-Paul