Home » Php » how to configuring a xampp web server for different root directory

how to configuring a xampp web server for different root directory

Posted by: admin November 29, 2017 Leave a comment


The web directory is the home of all of your application’s public and static files. Including images, stylesheets and JavaScript files. It is also where the front controllers live.

So the question is when i install and set up xampp my web directory is:


and I want to set it up for:


How to do it?
Now when I type in my browser the address: http://localhost/
I enter xampp\htdocs directory
and I want to type in my browser the address: http://localhost/
and enter xampp\htdocs\myproject\web directory


You can change Apaches httpd.conf by clicking (in xampp control panel) apache/conf/httpd.conf and adjust the entries for DocumentRoot and the corresponding Directory entry.
Just Ctrl+F for “htdocs” and change the entries to your new path.

  • Go to C:\xampp\apache\conf\httpd.conf
  • Open httpd.conf
  • Find tag DocumentRoot “C:/xampp/htdocs”
  • Edit tag to DocumentRoot “C:/xampp/htdocs/myproject/web”
  • Now find tag < Directory > and change it to < Directory “C:/xampp/htdocs/myproject/web” >

  • Restart Your Apache


You can change the port while you open your XAMP control panel, follow the steps:

  1. click on config net to the start button, and
  2. select httpd.conf, a text file will open
  3. check the file and file listen:80,
  4. once got listen:80 replace with listen:8080 and
  5. save in the the same folder.

Once done that, you will be able to start your local server.


ok guys you are not going to believe me how easy it is, so i putted a video on YouTube to show you that [ click here ]

now ,
steps :

  1. run your xampp control panel
  2. click the button saying config
  3. select apache( httpd.conf )
  4. find document root
  5. replace

DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">

those 2 lines || C:/xampp/htdocs == current location for root || change C:/xampp/htdocs with any location you want

  1. save it
    DONE: start apache and go to the localhost
    see in action [ watch video click here ]

I moved my htdocs folder from C:\xampp\htdocs to D:\htdocs without editing the Apache config file (httpd.conf).

Step 1) Move C:\xampp\htdocs folder to D:\htdocs
Step 2) Create a symbolic link in C:\xampp\htdocs linked to D:\htdocs using mklink command.

D:\>mklink /J C:\xampp\htdocs D:\htdocs
Junction created for C:\xampp\htdocs <<===>> D:\htdocs


Step 3) Done!


In case, if anyone prefers a simpler solution, especially on Linux (e.g. Ubuntu), a very easy way out is to create a symbolic link to the intended folder in the htdocs folder. For example, if I want to be able to serve files from a folder called “/home/some/projects/testserver/” and my htdocs is located in “/opt/lampp/htdocs/”. Just create a symbolic link like so:

ln -s /home/some/projects/testserver /opt/lampp/htdocs/testserver

The command for symbolic link works like so:
ln -s target source

target - The existing file/directory you would like to link TO.
source - The file/folder to be created, copying the contents of the target. The LINK itself.

For more help see ln –help
Source: Create Symbolic Links in Ubuntu

And that’s done. just visit http://localhost/testserver/
In fact, you don’t even need to restart your server.


XAMP on Bitnami (which is the only option now) apache settings are in bitnami.conf
At c:\Bitnami\wampstack-XXX\apache2\conf\bitnami\ or something.
httpd.conf does not affect anything now. Smells like a Google style decoy 😉