Relative Links

Relative Links

by Nacho S.S. -
Number of replies: 7
Hi.

I had in my "config.php" file the variable wwwroot set as: "http://www.myserver.com/moodledir".(Moodle is in an Intranet Server, not a public IP)

All was right until I noticed many people have to access moodle from abroad through a firewall by means of a URL:port translation.


(They type http://fw.domain.com:port (Public IP) and the firewall sends them to the internal intranet server)

The problem is that as they access by the firewall, when they click an absolute link within moodle they receive the "Page not found" message, so I need the all the moodle links to be relative.

How could I achieve this?

I have set the wwwroot variable to "/moodledir". Is it a good idea?
Do I have to change some links in the database?

Thanks.
Average of ratings: -
In reply to Nacho S.S.

Re: Relative Links

by Martin Dougiamas -
ምስሊ ናይ Core developers ምስሊ ናይ Documentation writers ምስሊ ናይ Moodle HQ ምስሊ ናይ Particularly helpful Moodlers ምስሊ ናይ Plugin developers ምስሊ ናይ Testers
The relative path should work fine for web access. I think the only problem you will have is that links in emails will not work - I can't even think of a way around this.
In reply to Martin Dougiamas

Re: Relative Links

by Nacho S.S. -
Well.

In order to solve the email problem I wrote the "http://" stuff before the $a variable in the language tool, it works!!!!

Thanks.
In reply to Nacho S.S.

Re: Relative Links

by Martin Dougiamas -
ምስሊ ናይ Core developers ምስሊ ናይ Documentation writers ምስሊ ናይ Moodle HQ ምስሊ ናይ Particularly helpful Moodlers ምስሊ ናይ Plugin developers ምስሊ ናይ Testers
Good hack for the subscription process! Unfortunately, the links in email sent from forums will still not work. Is it possible to set things up so the intranet people ALSO access the site via http://fw.domain.com:port ?
In reply to Martin Dougiamas

Re: Relative Links

by Nacho S.S. -
Hi.

Sending all people requests through the firewall could collapse the firewall and I think the Intranet interaction would become slower.

Mmmm, there are about 200 students which are on the Intranet. Only 2-3 teachers are about to access by the firewall.

The problem is on the teachers roof I guess.
The links in the emails starts all with :
"http://www.moodleserver.com/...."

The teachers then have to replace manually the string with "fw.domain.com:port"...

If I could guess the recipient of the email, then i could send a customised email to
these teachers. Could I?

Example: (next to de code that sets up and sends the email):

if recipient="name@server.es" then
link="http://fw....."
endif


Is it possible?
Where should I put this code?

Thanks!!!!!!!!!




In reply to Nacho S.S.

Re: Relative Links

by Martin Dougiamas -
ምስሊ ናይ Core developers ምስሊ ናይ Documentation writers ምስሊ ናይ Moodle HQ ምስሊ ናይ Particularly helpful Moodlers ምስሊ ናይ Plugin developers ምስሊ ናይ Testers

It would be a very nasty hack, but you could put such code inside the _cron functions for each module (in the lib.php file).

For example, in mod/forum/lib.php is a forum_cron() function.

At the very top of that function put a

$wwwroot = $CFG->wwwroot;  // to remember it
then inside the loop:
if ($userto->email == "blah@blah.com" ....) {
   $CFG->wwwroot = "http://fw.....";
} else {
   $CFG->wwwroot = $wwwroot;
}
In reply to Martin Dougiamas

Re: Relative Links

by Nacho S.S. -
Hi.

I will try with your "hacking code" in the "cron" functions.

First I will try it with the forum module, to see if it works, I hope so!!!

I will let you know if this hacking is ok.

Thanks a lot!!!

Nacho.