For example, forum posts that include emoticons have them saved as
<img src="http://141.89.100.242/moodle/pix/s/wideeyes.gif" alt="weitaufgerissene Augen" style="font-family: verdana,arial,helvetica,sans-serif;" />
Makes me wonder why these are not saved with relative URLs. After all, the file structure of moodle is fixed. Saving IP address seems legit only in the log and as lastIp in user table IMHO. Well, in uses like a stamp in quizes is also ok. But storing fully qualified URLs sounds wrong to me since it has to create problems when moodle is moved to another server or moodle server changes IP address or domain name.
Supposedly, export-import of courses fixes these but this is no way to go for server with a hundred courses.
Re: why is moodle storing full urls in the database
For better transportability, use your domain name.
Then "" would be "", and you could change your IP without trouble.
Re: why is moodle storing full urls in the database
Consider also people who change service provider to run moodle. Not likely they can retain their domain.
I think you are talking about the part above moodle folder. Relative url's within Moodle can be constructed relative to the moodle folder. Its actual name is irrelevant since it never has to be referenced explicitely.
For example, the relative url to the emoticon I gave as example would be
<img src="../../pix/s/wideeyes.gif" alt="weitaufgerissene Augen" style="font-family: verdana,arial,helvetica,sans-serif;" />
since forum's php files are two levels deep in the moodle folder.
Re: why is moodle storing full urls in the database
Example: The user profile page can print some of that user's forum posts. The forum posts are retrieved through the forum modules lib.php, and they are usually displayed by some script in /mod/forum/. However, in this context they would be displayed by a script in /user/, and so the "../../" scheme would break the smilies.
I didn't think too much about this, but it seems like a good reason at first glance.
Re: why is moodle storing full urls in the database
If not that, there must be another way
Re: why is moodle storing full urls in the database
The site "http://www.moodledomain.net" might be dropped from the front but I vote for URLs like "/path/from/root.html".
Re: why is moodle storing full urls in the database
Also, content often ends up in email, where all URLs need to be complete. How can we consistently convert all relative URLs to absolute URLs?
It was problems like this that caused the original decision to always use full URLs. We had a big discussion about it.
Re: why is moodle storing full urls in the database
When moving to another domain there is a search and replace of some sort to be done anyways, or is my logic incorrect here?
But I also think that absolute URLs are better than the relative ones. Sometimes, for example, I want to find out which places refer to some page. Grepping for "index.php" is quite meaningless. Ok, in a dynamic environment with concatenated paths and so on it tricky also, but impossible with the relative URLs.
Re: why is moodle storing full urls in the database
For various reasons, we run a few different installations of moodle on one server (completely different audiences and missions for each so each is customized differently). However, we often need to copy courses from one version to another (say http://mysite.edu/moodle1/ to http://mysite.edu/moodle2/). The complete url gets in the way in this case and requires changing many references. Is there already an easy way to handle this that I am missing? Or should I get to work on that search and replace feature?
Thanks,
Jodi
Re: why is moodle storing full urls in the database
when you copy courses between Moodle sites I suppose that you are using the backup/restore utility, isn't it?
If so, absolute links should be automatically changed without problems (the contents of the $CFG->wwwroot variable are detected and modified). Doesn't it work for you?
Ciao
Re: why is moodle storing full urls in the database
Using the backup and restore does work fine on a course by course basis. In most cases, however, it has been easier for me to copy a whole database in one shot to a new version - and that requires broader search and replace. BUT, I shouldn't have to do this again (famous last words), so finding a solution is not critical. Just wondering if anyone had come up with ways to easily change all url references behind the scenes.
Thanks!
Jodi
http://yoursite/admin/replace.php
Be careful, as you can obviously really break a site with this script.