Veera / Blog

Making XAMPP to serve any directory outside htdocs

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 _ element after changing the directory to your own folder.

    Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all

  3. Then search for this string: . 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).