Two address to enter one moodle

Two address to enter one moodle

by Ali Hastie -
Number of replies: 14
Picture of Particularly helpful Moodlers

Hi

We having been working on Moodle within the College's Intranet (using a ISA server 2004) and would still like to enter within the College's Intranet as well as over the Internet.  Two addresses to enter the same location.

Is it possible to have two addresses within the config.php file for our single Moodle installation? would i need to ammend other files?

Please can someone help as we require Moodle internally as well externally.

Thanks, Ali.

Average of ratings: -
In reply to Ali Hastie

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Two address to enter one moodle

by Ali Hastie -
Picture of Particularly helpful Moodlers

Hi Alan

thanks for the reply.  Spoke to our IT manager and he thinks that this solution would not work with the way the College has its setup.  Have you any other ideas?  would it not be possible to ammend the config.php (im not a php programmer) file to read the two addresses?

I read a post http://moodle.org/mod/forum/discuss.php?d=28416 where an individual recommended adding in the following code within the config file:

Original:
$CFG->wwwroot   = 'http://newtown-hs.powys.sch.uk/vle';

New:
$internal = FALSE;
if (substr($REMOTE_ADDR,0,3) == "10.") $internal = TRUE;
if (substr($REMOTE_ADDR,0,4) == "172.") $internal = TRUE;
if ($internal) {
$CFG->wwwroot = 'http://newtown-hs.powys.sch.uk/vle';
}
else  {
$CFG->wwwroot = 'https://schoolmail.newtown-hs.powys.sch.uk/vle';
}

I dont think the REMOTE_ADDR appeals to us.

Thanks again, Ali.

In reply to Ali Hastie

Re: Two address to enter one moodle

by Steve Power -

Ali

In our config.php I have replaced the line like:

$CFG->wwwroot = 'http://newtown-hs.powys.sch.uk/vle';

with

if ($_SERVER['HTTP_HOST'] == "http://intranet/vle") {
$CFG->wwwroot = 'http://intranet/vle';
} else {
$CFG->wwwroot = 'http://newtown-hs.powys.sch.uk/vle';
}

We are using IIS on a Windows server if you are using Apache you may need to replace the $_SERVER['HTTP-HOST'] but I am not sure as I do not know Apache at all.

Regards
Steve

In reply to Ali Hastie

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Two address to enter one moodle

by Ali Hastie -
Picture of Particularly helpful Moodlers

Hi Alan

Many thanks for your reply.  We tried the code Steve kindly posted but only works internally!! I will pass your post onto our IT manager as he controls the DNS etc. and I will let you know what happens.

If anyone else has any ideas please post, this would be much appreciated.

Thanks again, Ali

In reply to Ali Hastie

Re: Two address to enter one moodle

by Ali Hastie -
Picture of Particularly helpful Moodlers

Hi again

spoke to our IT manager and he has ammended the config file as follows:

if ($_SERVER['HTTP_HOST'] = 'internal address'){
$CFG->wwwroot = 'external address';
}else{
$CFG->wwwroot = 'http://webserv:8011';}

We can view homepage externaly and internally but can not log in.  when we try to log in (as admin, teacher and student) we are taken to the white screen with an error stating: 400 bad request.

We can can also get so far into to moodle but eventually receive the 400 bad request error.  It looks like we are very close, has anyone any ideas??

Thanks, Ali.

In reply to Ali Hastie

Re: Two address to enter one moodle

by Ali Hastie -
Picture of Particularly helpful Moodlers

P.S.

When we try to login within the internal side we receive this error:

Attachment Blocked

You do not have the permissions required to open or download e-mail attachments from this computer. Contact your server administrator for details about your user permissions.

Please Help!

Ali.

In reply to Ali Hastie

Re: Two address to enter one moodle

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Let's suppose your internal moodle URL is 'http://internal.name.or.ip:1234/' and your external moodle URL is 'http://external.name.or.ip:8765'. Then you could have something like this:

if ($_SERVER['HTTP_HOST'] == 'internal.name.or.ip') {
    $CFG->wwwroot = 'http://internal.name.or.ip:1234/';
} else {
    $CFG->wwwroot = 'http://external.name.or.ip:8765/';
}

Watch out. The first line doesn't have neither 'http://' nor ':1234', but the other to do. This _is_ important.

Saludos. Iñalki.
In reply to Iñaki Arenaza

Re: Two address to enter one moodle

by Ali Hastie -
Picture of Particularly helpful Moodlers

Hi Iñalki

thanks for your post.  This code works internally (intranet) to the max but does not work externally (internet).  This is happening with another piece of software (Web Wiz forum)  where we can view within the Intranet but not able to view it over the Internet.

would it have to do with something concerning our server, router or firewall setup?  I know nothing about server etc setup as I leave this to our IT manager, but he is away at the moment.

Please can anyone help?

Thanks, Ali

In reply to Ali Hastie

Re: Two address to enter one moodle

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Would it have to do with something concerning our server, router or firewall setup?

Most probably yes.

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Two address to enter one moodle

by Ali Hastie -
Picture of Particularly helpful Moodlers

Oh brother! our IT manager thinks that setup with mentioned hardware should not cause the problem!!

Has anyone out there had the same problem? I have looked through the forums for a few hours and have found certain areas but still unsure.

Please help!?

Thanks, Ali

In reply to Ali Hastie

Re: Two address to enter one moodle

by M Moodley -
Try:

$CFG->wwwroot = 'http://'.$_SERVER['HTTP_HOST'].'/yourdirectory'


Note the ' (Not clear on the screen)
Works on my instalation from both in and out of school. Hope is works for you - let me know.
Not sure where I got this solution from.


Mervyn
In reply to M Moodley

Re: Two address to enter one moodle

by Ali Hastie -
Picture of Particularly helpful Moodlers

Hi Mervyn

thanks for your post but im not sure about: Note the ' (Not clear on the screen)

Sorry!

Ali

In reply to Ali Hastie

Re: Two address to enter one moodle

by M Moodley -
Hi Ali:

Had my browser set to a low resolution and I could not see the apostiphy (') that I typed in!!

Mervyn