home

Making XAMPP to serve any directory outside htdocs

November 22, 2011 · 3 comments

So, you have installed XAMPP on windows, changed its server port to a different number other than 80 and changed the MySQL root password to a more secure one. Now its the time to create some HTML files that will be served by XAMPP server.

By default, XAMPP serves any file that is located under the directory [xampp_installation_folder]/htdocs,  which means that you have to copy all your HTML/PHP files inside this directory. But what if you maintain a different folder for all your projects files and you want XAMPP to serve them too along with htdocs?

Lets make XAMPP to do this.

  1. Open the file [xamp_installation_folder]/apache/conf/httpd.conf in any text editor.
  2. Copy below lines after the htdocs <Directory> element after changing the directory to your own folder.
    <Directory "C:/path/to/your/folder">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
  3. Then search for this string: <IfModule alias_module>. Inside that element, add a new alias as followed:
    Alias /yoursite/ "C:/path/to/your/folder/yoursite/"
  4. Save the file and restart the XAMPP server.
After this, if you have a website named ‘yoursite’ inside the folder ‘c:/path/to/your/folder’ you can access it directly by using the URL: http://localhost:8080/yoursite/ (assuming you have changed XAMPP port to 8080).

Related Posts

{ 3 comments… read them below or add one }

jigish November 25, 2011 at 9:10 PM

hey thanks for this wonderful post.. i was looking something similar :)

Reply

Raghavan alias Saravanan M November 27, 2011 at 4:00 PM

Hi Veera,

This is typically called as DocumentRoot in Apache, if I am right.

A good post though.

Reply

Jery January 13, 2012 at 9:19 PM

This worked for me the other day with XAMPP 1.7.6, php 3.5.5. Now it does not work with XAMPP 1.7.7 and php 3.5.8.

Reply

Leave a Comment

Previous post:

Next post: