Changing the URL of a Moodle instance later

Changing the URL of a Moodle instance later

- Visvanath Ratnaweera の投稿
返信数: 8
画像 Particularly helpful Moodlers 画像 Translators
Since the URL of a Moodle instance is stored in its configuration, if you happen to "move" an installation, say from http://mydomain/testmoodle/ to http://moodle.mydomain, needs a few tweaks.

What is the neat way of handling that?

The server is Linux with full (user and root) shell access.
Visvanath Ratnaweera への返信

Re: Changing the URL of a Moodle instance later

- J B の投稿
The site URL is set in the file /testmoodle/config.php as wwwroot.

Open config.php in a text editor, there will be a line:

    $CFG->wwwroot   = 'http://mydomain/testmoodle';

Change this to read:

    $CFG->wwwroot   = 'http://moodle.mydomain';
Job done.

J B への返信

Re: Changing the URL of a Moodle instance later

- Visvanath Ratnaweera の投稿
画像 Particularly helpful Moodlers 画像 Translators
That one is too good to be true!

Are you sure, for example, this URL is not stored in the database?
Visvanath Ratnaweera への返信

Re: Changing the URL of a Moodle instance later

- Howard Miller の投稿
画像 Core developers 画像 Documentation writers 画像 Particularly helpful Moodlers 画像 Peer reviewers 画像 Plugin developers
No it isn't stored in the database - UNLESS someone has placed a self-referring link somewhere in a resource.

It's kinda the point of the config file - vital information in one place ベー
Howard Miller への返信

Re: Changing the URL of a Moodle instance later

- J B の投稿
As Howard says.

It helps if your test moodle is in its own subdomain, e.g. test.mydomain.com so you can then structure relative links in the form

<a href="/course/view.php?id=5"> click here! </a>

then when you move the site to live.mydomain.com all the links will work.

J B への返信

Re: Changing the URL of a Moodle instance later

- Visvanath Ratnaweera の投稿
画像 Particularly helpful Moodlers 画像 Translators
Hi James

> It helps if your test moodle is in its own subdomain, e.g. test.mydomain.com so you can then structure relative links ...

Yes. I have it like http://moodle.mydomain for the production, http://moodle.mydomain/testmoodle/ for the test-run.

I really don't have control over what sort of URL links the course creators set. Will do a SQL dump and check.

Thanks for all the responses!

Visvanath


Visvanath Ratnaweera への返信

Re: Changing the URL of a Moodle instance later

- Howard Miller の投稿
画像 Core developers 画像 Documentation writers 画像 Particularly helpful Moodlers 画像 Peer reviewers 画像 Plugin developers
The only other thing you should watch out for is if you (or anybody else) has used self-referring links anywhere in resource texts. If that is the case and you have a manageable number of courses you may be better to use backup and restore which takes care of that kind of stuff.
Howard Miller への返信

Re: Changing the URL of a Moodle instance later

- Rory Allford の投稿
Does anyone know whether an SQL regex UPDATE is possible (in MySQL), and if so could it be used to change all the stored values of $CFG->wwwroot ? It'd be a nice trick to save doing a full site-wide backup/restore to correct the values.
Rory Allford への返信

Re: Changing the URL of a Moodle instance later

- Visvanath Ratnaweera の投稿
画像 Particularly helpful Moodlers 画像 Translators
That was my suspicion too. I expected a full database dump, a run through sed and a restore.

But all the Gurus say that is not necessary, "unless there are self-referencing links in content".