[localhost] How to change xampp localhost to another folder ( outside xampp folder)?

How can I change my default xampp localhost c:xampp/htdoc to another folder i.e. c:/alan? When I use the IP address I should be able to view my website file in C:/alan.

Thanks for helping me.

This question is related to localhost document-root

The answer is

Edit the httpd.conf file and replace the line DocumentRoot "/home/user/www" to your liked one.

The default DocumentRoot path will be different for windows [the above is for linux].

Please follow @Sourav's advice.

If after restarting the server you get errors, you may need to set your directory options as well. This is done in the <Directory> tag in httpd.conf. Make sure the final config looks like this:

DocumentRoot "C:\alan"
<Directory "C:\alan">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

steps :

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


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 ]

It can be done in two steps for Ubuntu 14.04 with Xampp 1.8.3-5

Step 1:- Change DocumentRoot and Directory path in /opt/lampp/etc/httpd.conf from

DocumentRoot "/opt/lampp/htdocs" and Directory "/opt/lampp/htdocs"

to DocumentRoot "/home/user/Desktop/js" and Directory "/home/user/Desktop/js"

Step 2:- Change the rights of folder (in path and its parent folders to 777) eg via

sudo chmod -R 777 /home/user/Desktop/js

just in case someone looks for this, the path to the file on Sourav answer (httpd.conf) in linux is /opt/lampp/etc/httpd.conf

On Linux Mint (Debian Based) go to /opt/lampp/etc/httpd.conf

Find YOUR_OWN_FILES_LOCATION to, of course, your files location.

    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/trunk/mod/core.html#options
    # for more information.
    #Options Indexes FollowSymLinks
    # XAMPP
    Options Indexes FollowSymLinks ExecCGI Includes

    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #AllowOverride None
    # since XAMPP 1.4:
    AllowOverride All

    # Controls who can get stuff from this server.
    Require all granted

@Hooman: actually with the latest versions of Xampp you don't need to know where the configuration or log files are; in the Control panel you have log and config buttons for each tool (php, mysql, tomcat...) and clicking them offers to open all the relevant file (you can even change the default editing application with the general Config button at the top right). Well done for whoever designed it!

For me it was on line 183, but it only works after you reboot your computer. I wish there was a way to quickly change it without having to reboot each time, but for now that's the only way I know how.

I had to change both the httpd.conf and httpd-ssl.conf files DocumentRoot properties to get things like relative links (i.e. href="/index.html") and the favicon.ico link to work properly.

The latest Xampp control Panel makes this pretty easy.

From the control panel, there should be Apache in the first row. If it's started, stop it. Then click config and open the httpd.conf file and search for htdocs or documentRoot. Change the path to what you like. Do the same for httpd-ssl.conf. These should be the top 2 files in the list under Config's dropdown.

Then start the server again.

Hope this helps someone. Cheers.

Questions with localhost tag:

Xampp localhost/dashboard Set cookies for cross origin requests Invalid Host Header when ngrok tries to connect to React dev server How to turn on/off MySQL strict mode in localhost (xampp)? What is IPV6 for localhost and How do I kill the process currently using a port on localhost in Windows? How to run html file on localhost? Can't access Server http:/localhost:8080 requires a user name and a password. The server says: XDB How to solve ERR_CONNECTION_REFUSED when trying to connect to localhost running IISExpress - Error 502 (Cannot debug from Visual Studio)? ngrok command not found Laravel 5 error SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) http://localhost/phpMyAdmin/ unable to connect Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) Can't connect to MySQL server on '' (10061) (2003) How to enable local network users to access my WAMP sites? How to send email from localhost WAMP Server to send email Gmail Hotmail or so forth? Accessing a local website from another computer inside the local network in IIS 7 http://localhost:8080/ Access Error: 404 -- Not Found Cannot locate document: / create a trusted self-signed SSL cert for localhost (for use with Express/Node) How to connect to mysql with laravel? mysqldump Error 1045 Access denied despite correct passwords etc HTTP Error 503. The service is unavailable. App pool stops on accessing website WAMP server, localhost is not working How do I use MySQL through XAMPP? Localhost : 404 not found How to change the URL from "localhost" to something else, on a local system using wampserver? Viewing localhost website from mobile device .htaccess not working on localhost with XAMPP #1045 - Access denied for user 'root'@'localhost' (using password: YES) How do I test a website using XAMPP? What is the right way to write my script 'src' url for a local development environment? Object not found! The requested URL was not found on this server. localhost IIS - can't access page by ip address instead of localhost Connect Device to Mac localhost Server? How to set xampp open localhost:8080 instead of just localhost correct configuration for nginx to localhost? Apache VirtualHost and localhost OAuth: how to test with local URLs? How do I connect to this localhost from another computer on the same network? How to change xampp localhost to another folder ( outside xampp folder)? Origin null is not allowed by Access-Control-Allow-Origin WAMP/XAMPP is responding very slow over localhost WAMP Server doesn't load localhost What is the difference between and localhost Localhost not working in chrome and firefox Accessing localhost:port from Android emulator How do you use https / SSL on localhost? Wireshark localhost traffic capture How to connect to my http://localhost web server from Android Emulator

Questions with document-root tag:

How to change xampp localhost to another folder ( outside xampp folder)? Where is the web server root directory in WAMP?