Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Configure Moodle for a New Domain

Move Moodle safely to a new domain by coordinating config.php, database content, moodledata, HTTPS, proxy settings, integrations and DNS in the right order.
Length12 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To move Moodle to a new domain, place the current site in maintenance mode, back up its database, copy the Moodle code and moodledata, configure the destination server, set the new fixed URL in config.php, repair absolute links with Moodle’s replacement tool, test every integration, and only then change DNS. Changing $CFG->wwwroot alone does not update URLs already stored in course content or file references.

The sequence below covers a hostname change such as moodle.old.example to https://learn.new.example, including an HTTP-to-HTTPS move. Adapt paths and database settings to your server layout and Moodle version.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What changes when Moodle gets a new domain

A Moodle domain move is more than a DNS edit. Four separate layers must agree on the new address:

Layer What you change Why it matters
Public address DNS records, firewall rules, load-balancer routing and any old-host redirects Users must reach the tested destination rather than the old server.
Moodle configuration The fixed $CFG->wwwroot value in the root config.php Moodle generates links, forms and callbacks from this canonical URL.
Application and data Moodle code, database, moodledata, database connection details, dataroot path, ownership and permissions The destination must contain the same site state and be able to read and write it.
Stored content Absolute links embedded in database content, including links to files and images Those values are not rewritten automatically when wwwroot changes.

Moodle’s configuration documentation says that wwwroot must be a fixed string constant pointing to the site; a dynamically detected URL is unsupported and can prevent command-line scripts from working. See the Moodle configuration-file documentation.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

If the scheme changes from HTTP to HTTPS, the certificate, public URL, web server or proxy and Moodle configuration must all describe HTTPS consistently. Moodle’s migration guidance is available in the Moodle migration documentation.

Prepare the move before touching DNS

Choose a maintenance window

Schedule a period when learners and teachers will not be editing courses, submitting assignments or sending messages. At the start of the window, enable Moodle maintenance mode from the administrator interface (the exact menu wording can vary by version). Keep the old site blocked from normal use throughout the copy and validation stages. This prevents new database rows or uploaded files from appearing on the old server after you have taken your backup.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Record the old and new values

Write down the complete old base URL, including its scheme and any subdirectory, and the complete new URL. For example, http://moodle.old.example/moodle and https://learn.new.example/moodle are different values from hostnames without a path. You will need the exact old value for the database replacement step. Also record the destination database name, username, password, database host, database port if applicable, and the absolute path that will be used as $CFG->dataroot.

Inventory integrations

List every service that may contain the old hostname: identity-provider callbacks, webhooks, mail links, calendar feeds, mobile or API clients, reverse-proxy rules, load-balancer health checks and firewall allow-lists. These are not all changed inside Moodle. The list becomes your post-move test plan.

Back up before migration

Make a verified backup of the Moodle database while the site is in maintenance mode. Retain a copy of the Moodle code and the moodledata directory as well. A backup is your rollback point if the replacement operation, permissions, plugin loading or an integration test fails. Do not overwrite the only copy of the old site until the new site has passed validation.

Move the Moodle files and database

1. Put the source site into maintenance mode

Enable maintenance mode, confirm that a normal learner account can no longer make changes, and wait for any already-running administrative operation to finish. Keep a note of the exact time so you can correlate database and web-server logs if a problem appears.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Back up the database

Use the backup utility appropriate to your database engine and save the resulting file outside the web root. Verify that the backup can be read or restored in a test location before relying on it. The database contains users, courses, settings and content that cannot be reconstructed by copying PHP files.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

3. Copy Moodle code and moodledata

Copy the complete Moodle application code to the destination, including plugins that are part of the current installation. Copy the entire moodledata directory to the new server and preserve its intended directory structure. The current migration guidance notes that the cache, localcache, sessions, temp and trashdir directories do not need to be copied; Moodle can recreate those working directories on the destination. Do not confuse those subdirectories with the rest of moodledata, which contains user files and other persistent data.

4. Restore the database and configure the destination

Restore the database backup into the destination database service. Configure the destination web server and PHP environment for the Moodle version already in use, then set the database connection values and dataroot path in config.php. The web-server account must be able to read the Moodle code and read and write the required data directories. Keep moodledata outside the publicly served document root unless your existing architecture explicitly requires another safe arrangement.

Check ownership and permissions before opening the site. A page that loads but cannot create a session, write a cache or serve a private file usually indicates an ownership or path error rather than a domain error.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set the authoritative URL in config.php

Use a literal, complete URL

Edit the config.php at the root of the Moodle code directory on the destination. Set $CFG->wwwroot to the exact public URL, including https:// and any Moodle subdirectory:

$CFG->wwwroot = 'https://new.example.edu/moodle';

Do not derive this value from the incoming HTTP host, environment variables or a runtime request. Moodle’s documentation states: “This setting must be a fixed URL (a string constant) that points to your site.” A fixed value lets web requests and command-line maintenance scripts use the same canonical address. The configuration-file reference also states that when a site changes from HTTP to HTTPS, this setting must be updated.

Keep the path consistent

If Moodle is served from /moodle, retain that path in wwwroot. Omitting it causes links and form actions to point at the wrong location; adding a path that the web server does not serve produces 404 errors. Conversely, if the new deployment moves Moodle from a subdirectory to the domain root, change the value to the root URL and make the web-server document root match it.

Configure HTTPS and reverse-proxy deployments

Direct TLS at the web server

In a direct TLS design, the web server that serves Moodle presents a certificate for the new hostname and receives HTTPS requests itself. Set wwwroot to the HTTPS URL, install a certificate whose names cover that hostname, and ensure HTTP traffic is redirected only after the HTTPS site has been tested. The certificate, virtual host and Moodle URL must use the same hostname.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

TLS terminated by a reverse proxy

Some deployments terminate TLS at a load balancer or reverse proxy and forward the request to Moodle over an internal connection. Moodle’s maintained configuration template documents $CFG->reverseproxy = true for reverse-proxy deployments and $CFG->sslproxy = true when an external SSL appliance terminates HTTPS. Enable these settings only when the architecture actually uses the corresponding proxy or SSL termination. Setting them on a direct web-server installation can make Moodle interpret requests incorrectly; omitting them in a terminating-proxy design can cause wrong-scheme redirects or mixed-content symptoms.

The proxy must pass the original host and scheme information in the manner expected by your web-server and Moodle configuration. Test both a normal browser request and a command-line script after enabling proxy settings. The maintained template is available at Moodle’s config-dist.php.

Decision Direct web-server TLS Reverse-proxy TLS termination
Administrative control Certificate and HTTPS virtual host are managed on the Moodle web server. Certificate, public listener and often redirects are managed at the proxy.
Proxy complexity No proxy-specific Moodle flags are needed. Forwarded host/scheme handling and the appropriate Moodle flags must match the architecture.
Failure to check Certificate or virtual-host mismatch can prevent access. Scheme or host mismatches can create redirect loops or insecure links.

Rewrite old absolute links in Moodle content

Why changing wwwroot is not enough

Course pages, labels, forum posts and other database content can contain complete URLs beginning with the old domain. Moodle does not rewrite every stored value merely because wwwroot changed. That is why images may still request the old hostname even though the login page displays the new one.

Run the administrator replacement tool

After the destination loads with the new wwwroot, sign in as an administrator and open:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
{wwwroot}/admin/tool/replace/index.php

Enter the old base URL exactly as it was stored and the new base URL exactly as it should appear. Review the values carefully before submitting. Run this operation only after taking the database backup described earlier. Do not use the replacement tool to change the wwwroot setting itself; that setting belongs in config.php. The replacement operation repairs absolute links in database content, including links to files and images.

Check for values outside Moodle’s database

The replacement tool cannot update a third-party identity provider, an external webhook endpoint, a proxy rule, a firewall allow-list or a hard-coded URL in a separate application. Use the integration inventory from your preparation step and change those systems independently.

Test before the DNS cutover

Use a temporary administrative mapping or an equivalent controlled test route so you can exercise the destination without sending all users there. Do not make the new hostname public until these checks pass:

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
  • Authentication: Sign in and sign out with an administrator and a normal learner account. Test the identity-provider callback if single sign-on is used.
  • Presentation: Confirm that CSS and JavaScript load from the new hostname and that browser developer tools show no requests to the old host or unexpected HTTP resources on an HTTPS page.
  • Navigation: Open the dashboard, a course, an activity, a forum and an administration page. Follow links that leave and return to Moodle.
  • Files and images: Open embedded images, download a course file, upload a small test file and check a private file that requires authentication.
  • Data writes: Submit a form, post a forum reply or make another safe test change, then verify it appears after a fresh login.
  • Automation: Run or observe cron, scheduled tasks and email integrations. Check that generated links use the new scheme and hostname.
  • Extensions: Exercise plugins, webhooks, API clients and identity-provider callbacks that were listed during preparation.
  • Operations: Confirm that logs are written, the web process can access moodledata, and the database connection remains stable.

If any test still references the old domain, locate whether the value comes from database content, a plugin setting, an external service or a cached browser response before proceeding.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Change DNS and complete the cutover

Make DNS the final routing change

After application testing, point the new hostname at the destination and update any firewall, load-balancer or reverse-proxy rule that controls traffic. DNS is a cutover step, not the first configuration change: changing it before the destination is ready sends users to an untested installation.

Handle the old hostname deliberately

Where policy and authentication design allow it, keep the old hostname available long enough to issue redirects to the new canonical URL. A redirect cannot fix links embedded in a third-party system, so update those integrations as well. Do not redirect until the new certificate and proxy route work, and avoid leaving two independently writable Moodle instances online.

Take the new site out of maintenance mode

Once DNS resolution, login, content, integrations and background tasks have been verified through the public hostname, disable maintenance mode on the destination. Keep the old server and its backup available until you have observed the cutover and confirmed that no essential workflow is failing.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot the most common failures

Images or downloads still use the old domain

Check the exact old and new base URLs and run the administrator replacement tool. Changing wwwroot does not alter absolute links already stored in database content. If only one plugin or integration is affected, inspect that plugin’s own settings rather than repeatedly changing the global URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Redirect loops or links switch between HTTP and HTTPS

Confirm that wwwroot uses https://, that the certificate covers the requested hostname and that the proxy or web server is forwarding the original scheme correctly. In a terminating-proxy design, review whether $CFG->reverseproxy and $CFG->sslproxy reflect the actual architecture. Do not enable either flag simply to suppress a symptom on a direct HTTPS server.

Command-line scripts stop working

Inspect config.php for a dynamically generated wwwroot. Moodle requires a fixed URL string; command-line scripts do not have a browser request from which to infer a host. Replace the dynamic expression with the literal public URL.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

CSS or JavaScript returns 404 errors

Verify that the URL includes the correct subdirectory, that the destination web root points to the Moodle code directory, and that the copied code matches the database and plugin set. A missing path segment in wwwroot commonly produces links that look valid but point outside the virtual host.

Users cannot log in or sessions disappear

Check that the destination can write the required session and cache locations, that ownership matches the web process, and that the proxy presents a consistent host and scheme. If only the new hostname fails, inspect cookie scope and any identity-provider callback configured with the old hostname.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Files are missing after the move

Confirm that the complete persistent portion of moodledata was copied and that $CFG->dataroot points to that exact absolute path. The cache, localcache, sessions, temp and trashdir directories may be recreated, but omitting user-file data is not a valid shortcut.

Choose an implementation approach

The same URL procedure applies whether you operate the infrastructure yourself or use a managed service, but responsibilities differ. Use this comparison when planning the move.

Approach Administrative control Proxy complexity Backup responsibility Maintenance access Version compatibility
Self-managed VPS, direct web-server TLS Highest control over web server, PHP, database and DNS. Low if no reverse proxy is present. You create, verify and retain database, code and moodledata backups. You can place the site in maintenance mode and edit config.php directly. You must match the destination environment to the Moodle version and installed plugins.
Self-managed VPS behind a reverse proxy Control is split between the proxy and the Moodle server. Higher; forwarded host and scheme handling must be correct. You must back up both Moodle data and any proxy configuration needed for recovery. Maintenance and troubleshooting involve two layers. Proxy settings must remain compatible with the Moodle version in use.
Managed Moodle hosting The provider may control web-server, database and DNS operations; the exact division is provider-specific. Not stated; ask how TLS termination and forwarded headers are handled. Confirm what the provider backs up and whether you can download an independent database copy. Confirm that you can enable maintenance mode, obtain config.php changes and run the replacement tool. Verify support for your Moodle version, plugins and required integrations before scheduling the move.
Manual database replacement Direct control over when the replacement is executed. Independent of proxy design. Requires a verified backup immediately before the change. You must schedule maintenance and perform the administrator operation yourself. Use Moodle’s replacement tool and follow the version-appropriate migration guidance.
Scripted, backed-up replacement process Repeatable and auditable when carefully implemented. Independent of proxy design. Automation should stop unless a fresh backup succeeds and should preserve logs. Requires a tested runbook and a safe rollback path. Validate scripts against the Moodle version; never assume database internals are unchanged.

Rollback and post-cutover care

If a critical test fails after DNS changes, place the new site back into maintenance mode, restore routing to the old site only if it was kept unchanged and writable state can be reconciled, and investigate from the preserved backup. Do not let users write to two divergent Moodle databases while deciding what to do. If the replacement operation itself caused the problem, restore the pre-replacement database backup on a controlled copy rather than attempting ad-hoc reverse substitutions.

After the move is stable, remove temporary test mappings, update documentation and run one more search for the old hostname in integration settings and operational configuration. Retain the migration backup according to your organization’s recovery policy, and keep the old server available until the agreed observation period has ended.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.