c0der c0der - 4 months ago 21
PHP Question

How to Change the www root directory on WampServer 2.5

My need is to change the default sites directory of wamp from say "c:\wamp\www" to say "d:\sites".
Right now my projects in "d:\sites" do not show in the project list:

enter image description here

I found a few past answers like this one and this one which I think are not applicable to WampServer 2.5 (anyway, it did not work for me).

I also found this procedure in the documentation, but it seems far too complex for what I need.

Any help on this matter would be appreciated.

Answer

I figured out a way to do what I needed. To get the projects appear on the WAMP start-up page I did the following changes in index.php (stored under the original wamp/www/ folder): Changed this code:

// récupération des projets
$handle=opendir(".");
$projectContents = '';
while (($file = readdir($handle))!==false) 
{
    if (is_dir($file) && !in_array($file,$projectsListIgnore)) 
    {       
        //[modif oto] Ajout éventuel de http:// pour éviter le niveau  localhost dans les url
        $projectContents .= '<li><a href="'.($suppress_localhost ? 'http://'   : '').$file.'">'.            

       $file.'</a></li>';
    }
}
losedir($handle);

into this:

// récupération des projets

//A new varible which represents the path of the new www folder
$www_dir = "D:/sites/";

$handle=opendir($www_dir);//modified to open the new folder 

$projectContents = '';
while (($file = readdir($handle))!==false) 
{
    //added the path to the folder name for is_dir test
    if ( is_dir($www_dir.$file) && !in_array($file, $projectsListIgnore) ) 
    {
        //[modif oto] Ajout éventuel de http:// pour éviter le niveau localhost dans les url
        $projectContents .= '<li><a href="'.                                    
            ($suppress_localhost ? 'http://' : '').$file.'">'.$file.'</a></li>';
    }
}
closedir($handle);

Note: this change makes the projects stored under D:/sites/" show as links, but the links are not working.