Links and moving Moodle

Links and moving Moodle

by Rick Hatton -
Number of replies: 4

I often move Moodle installs between servers. While making a lesson activity, I linked to files in my repository. I noticed the link showed the full path. Are these links hard written, or are they relative and just look like a full path? In other words, If I move my install to another server, will I have to fix those links?

Any and all help appreciated.

Average of ratings: -
In reply to Rick Hatton

Re: Links and moving Moodle

by Ken Task -
Picture of Particularly helpful Moodlers

Think all internal to server links take the value of the $CFG->wwwroot (http thingy) and builds full URL's to resources ... ie, not relative addressed.

'spirit of sharing', Ken

In reply to Ken Task

Re: Links and moving Moodle

by Rick Hatton -

Thanks smile

In reply to Rick Hatton

Re: Links and moving Moodle

by Ken Task -
Picture of Particularly helpful Moodlers

There is an easy fix ... before moving ...

download the backup .sql file to be used for importing on the new system and edit with an text editor: search for http://oldsite/[folder]/ replace with http://newsite/[folder]/

If you have command line on either server can edit the sql dump there using editors such as nano.

or after moving, use the admin tool for search and replace in Moodle:

http://newsite/admin/tool/replace/

use the full URL to search ... ie, http://oldsite/[folder]/ and replace with (as above) http://newsite/[folder]/

'spirit of sharing', Ken

In reply to Ken Task

Re: Links and moving Moodle

by Bret Miller -
Picture of Particularly helpful Moodlers

I find that most links on our Moodle website are absolute, that is they include the full URL. The last time I tested this, it was almost impossible to create a relative URL link. Admittedly that was a few version ago.

We also regularly clone the live Moodle website for testing. The script we wrote uses sed to replace the URL along with some other settings in the data, but HTML blocks are somehow encoded so that sed command doesn't fix the URLs in those blocks. That we do after the site is restored using the search and replace tool Ken mentioned.