90

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.

Zeeshan Hassan Memon
  • 8,105
  • 4
  • 43
  • 57
enrekan2011
  • 911
  • 1
  • 7
  • 6

9 Answers9

85

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].

Sourav
  • 17,065
  • 35
  • 101
  • 159
  • 1
    thanks for your quick respond and answer my question. can you tell me which line i suppose to change it?because i have change it..but it doesn't work for me. – enrekan2011 Jan 13 '12 at 08:31
  • 6
    try restarting the apache server – user1006274 May 23 '14 at 17:53
  • You better make backup configuration file with other name, for can restore configuration in case wrong settings – Ivan Pirus Feb 22 '17 at 18:10
  • sidenote: if you want to completely move xampp, this will not be enaugh, altough it is 100% more easy to just (temporarily) put your xampp in the default path while you are working on desired project. – jave.web Feb 27 '17 at 08:45
  • Do you have to restart your browser as well? – Kellen Stuart Jul 10 '17 at 17:25
  • There's a hidden notice in the answer: You **must not** save the path as a relative one using a tilde symbol (`~`), even by adding a username (e.g. `~username`). If so, starting/stopping Apache in XAMPP will fail. – MAChitgarha Jul 22 '18 at 15:41
33

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
</Directory>
mingos
  • 23,778
  • 12
  • 70
  • 107
  • thanks for your quick replay..im appreciated it..can you tell me which line i need to change it.? – enrekan2011 Jan 13 '12 at 08:29
  • Sorry, can't help you there. Just search for "DocumentRoot" in your php.ini. The `` part should be somewhere after it, but as I use a different server and on a different platform, I don't really have the means to check for sure. – mingos Jan 15 '12 at 23:07
28

steps :

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

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 ]

insCode
  • 1,227
  • 14
  • 10
12

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

nrussell
  • 18,382
  • 4
  • 47
  • 60
Mrityunjai
  • 163
  • 2
  • 8
11

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

igrossiter
  • 744
  • 1
  • 12
  • 26
5

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

Find YOUR_OWN_FILES_LOCATION to, of course, your files location.

DocumentRoot "YOUR_OWN_FILES_LOCATION"
<Directory "YOUR_OWN_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
</Directory>
Adelin
  • 18,144
  • 26
  • 115
  • 175
2

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.

Hooman
  • 21
  • 2
2

@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!

Francis
  • 702
  • 9
  • 21
1

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.

Harry Robbins
  • 530
  • 4
  • 17