Home > Chamilo, Documentation, English, Techie > Answering to different addresses with Chamilo

Answering to different addresses with Chamilo

One possible annoying element of Chamilo is it can only answer to one address at a time. This simply comes from a very old codebase and the fact that, at some point in the past, it wasn’t that easy to get the address from the URL or the HTTP headers in a reliable way.

Nowadays, though, it’s completely reliable to say that your host is (in PHP) $_SERVER[‘HTTP_HOST’], so you could hack the configuration file of Chamilo (main/inc/conf/configuration.php) like this:

  $_configuration['root_web'] = 'http://my.chamilo19.net/';
  if (!empty($_SERVER['HTTP_HOST'])) {
    $_configuration['root_web'] = 'http://'.$_SERVER['HTTP_HOST'].'/';

This might have a security impact, we are still assessing this. However, it is likely that this does not really impact security, as other similar systems (like Drupal, Joomla, etc) also let the HTTP_HOST determine the web root path. One alteration to this would be to manually allow for the definition of a “list” of authorized hosts.
If we cannot find any clear reason to prevent the use of this technique in Chamilo, it is likely versions starting from 1.10 will rely on this to avoid the strict dependency on the host defined in $_configuration[‘root_web’].
There will likely be a requirement on $_SERVER[‘SERVER_PROTOCOL’] as well to identify cases where we use HTTPS (SSL certificates).

Kudos to GMP Perú for passing this requirement on to us so we could work on it and find a good solution.

2014-02 edit:
Another customer has reported that, when using what they call a “safe browser” (proprietary piece of software, as far as we could tell), they ran into issues when moving to the next question in an exam.

Apparently, the so called “safe browser” tries to force HTTPS on top of a non-HTTPS communication, or to proxy the URLs in some way. This falls into the same kind of issues as above, as the server does not accept different URLs.

To fix this, we had to include HTTPS processing to the above code:
  $_configuration['root_web'] = 'http://my.chamilo19.net/';
  if (!empty($_SERVER['HTTP_HOST'])) {
    if (!empty($_SERVER['HTTPS'])) {
      $_configuration['root_web'] = 'https://'.$_SERVER['HTTP_HOST'].'/';
    } else {
      $_configuration['root_web'] = 'http://'.$_SERVER['HTTP_HOST'].'/';

2014-04 edit:

It seems that more and more weird requirements are appearing around this. Another customer wants to support both a local IP address with a sub-folder in which Chamilo lies (for example *and* a normal public domain like http://my.chamilo19.net/.

This is a slight issue in Chamilo, as we clearly differenciate between installations in a subfolder and installations in a “root” folder (o better said, “root domain path”).

Nevertheless, the following has been lightly tested and seems to be working just fine, as the only difference between sub-folder mode and root folder mode is the url_append element of the $_configuration array.

  // "/chamilo" is the subfolder, "" is the local IP,
  // "my.chamilo19.net" is the "root domain"
  $_configuration['url_append'] = '/chamilo';
  $_configuration['root_web'] = '';
  if (!empty($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] != '') {
    if (!empty($_SERVER['HTTPS'])) {
      $_configuration['root_web'] = 'https://my.chamilo19.net/';
    } else {
      $_configuration['root_web'] = 'http://my.chamilo19.net/';
    $_configuration['url_append'] = '';

This type of configuration will NOT work, however, with a single SSL certificate, and will definitely not work with the IP address (you need to define a real host name to get a certificate for).

  1. November 19, 2016 at 1:04 am

    Ho Yannick I desperately need you help Please…

    We have setup Chamilo on a windows server.

    We have two VLANS 1 for staff and one for learners, reason is that learners are NOT allowed free access to the internet through the wifi. The IP address for the students is…. Staff are on the other IP address – the staff need internet access to check emails and upload to Chamilo

    I have Chamilo 1.11.2 using XAMPP installed on

    Everything works fine when logged into the staff or ip range,

    HOWEVER when the learners access through the STUDENT with ip chamilo wants to find address which is blocked for them

    Is there a way to get chamilo to see or accept the two IP addresses?

    Please Please we have 1250 learners on site and nothing is working



    • Yannick Warnier
      November 19, 2016 at 1:49 am

      Hi Gary,

      Applying the technique above should work in your case (just replace the domain name by the different IP addresses).
      Alternatively, if you have control over an internal DNS or DHCP server, you should be able to setup an internal name that points to each IP in their corresponding VLANs.

      If you can’t set it up, the question that comes up is how you suddendly got 1250 learners with a non-working network setup…!? You should prepare for this kind of load well in advance.

      • November 20, 2016 at 8:57 pm

        Hi Yan

        Will try asap. If I may explain a little bit more. We had a Linux server with moodle installed. The company that installed the system closed their doors. Last week on arrival at school the portal was down and would not start up. We then decided to format off and re-install windows server. Please if you don’t mind any help with regards to the above is much appreciated. Regards Gary

  2. Yannick Warnier
    November 20, 2016 at 11:50 pm

    Hi Gary, we don’t recommend nor provide services on Windows servers, so it would be a bit difficult for me to help you. This being said, my comments above and the initial article are still valid and should still work.

  3. November 26, 2016 at 9:01 am

    Hi Yannic, thank you for your help with the above. Hope you can suggest one thing please Sir. I installed Chamilo on and used the above code as you suggested with regards to getting the student network up… All good except for picture links…

    If I upload a picture to the portal home page It shows a broken link… I noticed that it defaults to This only happens with images it seems. Please Sir, any ideas…

    Here is the substitutions made to the code suggested… have I done something wrong here maybe?

    * Directory settings
    // URL to the root of your Chamilo installation, e.g.: http://www.mychamilo.com/
    //$_configuration[‘root_web’] = ‘’;
    // “/chamilo” is the subfolder, “” is the local IP,
    // “my.chamilo19.net” is the “root domain”
    $_configuration[‘url_append’] = ‘’;
    $_configuration[‘root_web’] = ‘’;
    if (!empty($_SERVER[‘HTTP_HOST’]) && $_SERVER[‘HTTP_HOST’] != ‘’) {
    if (!empty($_SERVER[‘HTTPS’])) {
    $_configuration[‘root_web’] = ‘’;
    } else {
    $_configuration[‘root_web’] = ‘’;
    $_configuration[‘url_append’] = ‘’;

    If i log into the student network all is fine and we can see the picture, why is it omitted from the ip?
    Your help is much appreciated Yannick…

  4. Yannick Warnier
    November 26, 2016 at 9:27 am

    Hi Gary, if you are going to want to configure complex situations like this, you should really take a programming course. Otherwise anything I can help you with will create a dependency on me helping you.

    You code should be like this:

    $_configuration[‘url_append’] = ‘Chamilo/’;
    $_configuration[‘root_web’] = ‘’;
    if (!empty($_SERVER[‘HTTP_HOST’]) && $_SERVER[‘HTTP_HOST’] != ‘’) {
    $_configuration[‘root_web’] = ‘’;

    url_append is just the part of the URL that comes after the host.
    As you are using an IP address, there’s not much chance you are using HTTPS at all, so I disabled that.

    Also, please note that when you upload an image as part of a document, sometimes the editor will save the image link with the full URL. This should be fixed by editing the HTML document source (one of the last icons in the editor) and removing the par, just leaving the initial / and the url_append, like this (for example):

    … src=”/Chamilo/courses/ABC/document/image.png” (instead of src=” etc).

    This will ensure the link is relative to the base of your portal, independent of the IP address.

  5. November 26, 2016 at 10:29 am

    Thank you Yannick will try… Thank you again for the advice it is really appreciated.

  6. February 3, 2017 at 3:41 pm

    Good day Yannick

    Firstly thank you for all the help thus far kids are working the Chamilo portal and all is well.
    A question please Yannick

    We have decided to open the portal for kids to access from outside the school. The tech guys have made it possible to see the address for us. Chamilo however is not showing up correctly.

    the previous code you gave me to add to chamilo configuration was
    $_configuration[‘url_append’] = ‘Chamilo/’;
    $_configuration[‘root_web’] = ‘’;
    if (!empty($_SERVER[‘HTTP_HOST’]) && $_SERVER[‘HTTP_HOST’] != ‘’) {
    $_configuration[‘root_web’] = ‘’;

    How do I add that chamilo should see this address aswell


    Please Yannick, I am learning as I go…

    Thanking you in advance

    Gary Berends

    • Yannick Warnier
      June 28, 2017 at 6:32 pm

      Hi Gary, the article has been updated in March with new special cases. Hope this helps.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: