VirtualHost with Joomla

From Joomla! Documentation

Revision as of 09:00, 2 August 2008 by Erdsiger (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

It is also related to debugging between localhost or

Q: Unable to view my site properly from my debug domain name:, only from localhost that it is displayed properly. Is there a way to make the transition automatic!


The 'problem' is related to the variable $mosConfig_live_site. When changing from localhost to we assume that your site is going live. Therefore, you want to update the $mosConfig_live_site variable in the configuration file.

If you need to perform other test with a temporary "almost" live site then you would have to change that variable every time.

Now, you could also modify your configuration file like this.

Change this line

    $mosConfig_live_site = 'http://localhost/myvirtualdirectory';


    $mosConfig_live_site = getLiveSite();  //'http://localhost/myvirtualdirectory';

At the bottom of the file and BEFORE the php closing bracket "?>", add the following function:

    function getLiveSite(){
    $s = empty($_SERVER["HTTPS"]) ? ''
          : ($_SERVER["HTTPS"] == "on") ? "s"
          : "";
       $proto = explode('/', $_SERVER["SERVER_PROTOCOL"]);
       $protocol = strtolower($proto[0]).$s;
       $port = ($_SERVER["SERVER_PORT"] == "80") ? ""
          : (":".$_SERVER["SERVER_PORT"]);
       $getVD = explode('/', $_SERVER['PHP_SELF']);
       if(count($getVD) <=2 ){
          $virtualdir = '';   
          $virtualdir = '/' . $getVD[1];
       return $protocol."://".$_SERVER['SERVER_NAME'].$port. $virtualdir;