Changing DocumentRoot - Problems

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Changing DocumentRoot - Problems

Postby reconstrukt » 20. January 2008 00:56

Hi there

I am migrating to a new laptop, and installed XAMPP/Windows XP Pro.

I have 50 or so sites/web apps/projects on my hard drive. All the source for these projects is located within their own directory under c:/mjk, or - for example, "c:/mjk/project_name/htdocs"

On my old laptop, I would simply open my httpd.conf, and I had multiple (commented) lines setting the DocumentRoot variable to point to the proper directory.

So, let's say I want to work on "my_project"

I would just open httpd.conf, comment out the existing DocumentRoot, and uncomment this line:

#DocumentRoot "C:/mjk/my_project/htdocs"

And restart Apache. Done.

Why can't I do this on XAMPP?

Now, running XAMPP, whenever I change the DocumentRoot variable, I get this error: "503 Forbidden". In my error.log I get this: "client denied by server configuration: C:/mjk/my_project/htdocs"

Can someone please help. This is absolutely maddening - something so simple on my old laptop is now just plain broken.

Posts: 2
Joined: 20. January 2008 00:42

Postby Scory » 20. January 2008 01:10

Read and analyze your httpd.conf carefully - you will find a <directory>-Block which grants special rights to the DocumentRoot folder (which is xampp/htdocs per default).

You have to change the value of path in this block also to your new folder.

Postby reconstrukt » 20. January 2008 14:16

I'm not "reorganizing" my data. We're talking about 50+ sites/apps. with their own directory structures that include source, among other things (media, PSDs, docs, etc). I can't just start moving those sites around on my hard drive (and i shouldn't have to!!!)

I've resolved the problem - and am posting it here for others...

Xampp's default httpd.conf has a very restrictive set of <Directory> vars.

For example:

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all

This will block any pages that you try to serve outside of a specified vhost. For a production server, this is very safe. But since Xampp is a development environment (I would never use Xampp on a production web server, even the Xampp team themselves advises against it) - we can make some changes.

If you don't want to use vhosts, and simply want to work by changing the "DocumentRoot" variable, then change the whole <Directory> block to read:

<Directory />
Options FollowSymLinks
AllowOverride None
Allow from all
#Order deny,allow
#Deny from all

Notice I've commented out the "Order deny,allow" and "Deny from all" lines, and added a line to "Allow from all". This means Apache can server documents from anywhere on your hard drive.

Now, DocumentRoot can be set to any location on your machine.

That's it!

Posts: 2
Joined: 20. January 2008 00:42

Postby LooseCannon » 21. January 2008 18:02

Hello and welcome reconstrukt. I'm glad you've spotted how restrictive XAMPP makes the default document root and got your setup working as you'd like.

Thank you for the clear feedback and answer that you've provided.

Out of interest, may I ask why you don't use virtual hosts and hence not have to stop/start Apache when wanting to change the web site you're working on or looking at? I have no problem with you liking your solution. I'm learning this stuff and like dumb questions, which often provide my biggest lessons. ;)
User avatar
Posts: 162
Joined: 18. September 2007 12:07
Location: Hampshire, UK

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 101 guests