Apache alias to the default DocumentRoot

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

Apache alias to the default DocumentRoot

Postby nutkenz » 14. December 2006 16:06

PROBLEM SOLVED! Don't bother reading this unless you're having the same issue I had.

Okay, I've been trying to get this to work for over an hour now, but I kept getting either a 403 or a 404 error no matter what I try...

My DocumentRoot is "D:/Webs" because my websites are stored there. I want to have access to the XAMPP control panel though, so I thought I'd define an Alias: Alias /config/ "C:/Program Files/xampp/htdocs"

Of course I need to allow access outside of the DocumentRoot, so I added this Directory entry:

Code: Select all
<Directory "C:/Program Files/xampp/htdocs">
   Options Indexes MultiViews FollowSymLinks Includes
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>


The result:

URL http://localhost/config/index.html
LOG 127.0.0.1 - - [14/Dec/2006:15:52:54 +0100] "GET /config/index.html HTTP/1.1" 403 1147
ERR [Thu Dec 14 15:53:35 2006] [error] [client 127.0.0.1] client denied by server configuration: C:/Program Files/xampp/htdocsindex.html

So I figured I'd have to add a trailing slash to the alias destination path as such: Alias /config/ "C:/Program Files/xampp/htdocs/"

That produces a nice "It works!" page, but when I now visit http://localhost/config/ instead of http://localhost/config/index.html, I'm being redirected to http://localhost/xampp/ which points to D:\Webs\xampp

While writing this I figured out that there's also an index.php file which takes priority over the .html and is causing the redirect :oops:. I'll post this anyway in case anyone else is having similar problems and stumbles upon this page.

The solution:
Code: Select all
Alias /config/ "C:/Program Files/xampp/htdocs/xampp/"


http://uwhost.net
nutkenz
 
Posts: 12
Joined: 14. December 2006 11:45

Postby Izzy » 14. December 2006 23:14

nutkenz wrote:The solution:
Code:
Alias /config/ "C:/Program Files/xampp/htdocs/xampp/"

Of course the most effective way of doing this is to only have one index file in a directory not 2 as you have at the moment.
Just rename the index.php to index_orig.php then your index.html will be processed, problem solved, too easy.

...or you could change the priority order of the index file in these lines in the xampp\apache\conf\httpd.conf file or in a <Directory> container in a xampp\apache\conf\extra\httpd-vhosts.conf file:
Code: Select all
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
</IfModule>

Apache processes this list in order so if it finds an index.php and an index.html in the same directory it will process the index.php first.

So to change this behaviour you would change the order like so:
Code: Select all
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php index.php4 index.php3 index.cgi index.pl index.shtml index.phtml
</IfModule>

Now when Apache finds these 2 files in the same directory it will process the index.html not the index.php.
In this case to process the index.php not the index.html you would have to call it in the address line:
http://address.tld/index.php
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 49 guests