Change localhost/moodle URL

Change localhost/moodle URL

by Ryan Gilbert -
Number of replies: 4

Moodle 3.0.3+

PHP 562

SQL Server 2014


I have changed the default Moodle URL to http://moodle.domain.com/moodle and it works fine.  What I would like to do though is get rid of having to use the /moodle at the end as this will be a public facing website where it would be nice just to only have to put in a basic URL.  I'm sure it's something easy, but I've been screwing around with it for a little while now, and have gotten nowhere


Average of ratings: -
In reply to Ryan Gilbert

Re: Change localhost/moodle URL

by Ken Task -
Picture of Particularly helpful Moodlers

Looks/sounds like Windows platform .... didn't mention web server ... but *IF* you were on Linux and had full access to httpd.conf file (apache web server config) one could change what apache uses for document root ... on CentOS/LSB Linux flavored boxen that's /var/www/html/

Change that to /var/www/html/moodle/

Restart apache ... then anyone going to http://URL/moodle would get an error but anyone going to http://URL/ would see a whacky Moodle site.

To fix the whacky:

edit config.php file in Moodle code and change the $CFG->wwwroot variable.

and lastly ... since all internal links to Moodle are actually built from DB records:

Do an sql dump of the database and with a text editor search and replace for:

http://site/moodle/ replace with http://site/

Re-import the edited sql file to  new/fresh DB for Moodle.

Yes, there is a search and replace tool in Moodle code ... if one can get to it.

Change config.php file again for the new DB name, credentials.

Lastly ... manually remove contents of moodledata/cache/ and moodledata/localcache/ directories ... Moodle caches tons.

And just to make sure everything will come up as expected in case of a reboot/network outage, reboot server.   Check server error logs ... especially apache error logs.

Go to site and hopefully one can use the change without any hickups.

Is there any easier way?   Well, this is a community ... so let's see if anyone else has a 'shortcut'. ;)

'spirit of sharing', Ken


In reply to Ken Task

Re: Change localhost/moodle URL

by Ryan Gilbert -

Oh shoot, you're right. I forgot the most basic part. It's Windows 2012 R2 with PHP/IIS

In reply to Ryan Gilbert

Re: Change localhost/moodle URL

by Ken Task -
Picture of Particularly helpful Moodlers

Well, if you can translate 'Linux-speak' to 'Windows-speak', then what I've described could still work.   Then again, am not a Windows user/admin.    Maybe a Windows person will respond.

'spirit of sharing', Ken

In reply to Ken Task

Re: Change localhost/moodle URL

by Ryan Gilbert -
Thanks Ken! I think I may be able to translate that into Windows. I'll give it a shot and let you know if that works. If it doesn't work, that's what snapshots are for!