Cannot acces http://localhost/htdocs/

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

Cannot acces http://localhost/htdocs/

Postby peterswa62 » 09. February 2012 10:50

I get http://localhost alright but when I type http://localhost/htdocs/ in the browser it says object not found. This means I cannot use the htdocs folder for development work.

In the file httpd-vhosts.conf I added this:-

<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>

But it doesn't work.

Anyone any ideas why this happens and how to fix it?
peterswa62
 
Posts: 1
Joined: 09. February 2012 10:42
Operating System: XP

Re: Cannot acces http://localhost/htdocs/

Postby JonB » 09. February 2012 12:48

umm - localhost IS htdocs :shock:

the reason you can't access http://localhost/htdocs is that you don't have a directory called 'htdocs' UNDER 'xampp\htdocs'

for this "http://localhost/htdocs" to work your folder would have to be "xampp\htdocs\htdocs"

xampp\htdocs is the DocumentRoot - that's where the 'public space' of your Apache server begins.

If you are wondering why the XAMPP welcome page is served when you go to http://localhost, its because of the DirectoryIndex Apache Directive in xampp\apache\conf\httpd.conf - that determines the order in which Apache will serve various pages when you navigate to a folder in your browser and do not specify the file to be served, such as http://localhost -

Code: Select all
<IfModule dir_module>
    DirectoryIndex index.html index.php index.pl index.cgi index.asp index.shtml index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>


in a default XAMPP install, index.php would be first on that list, and it is a redirect to /xampp/

Code: Select all
<?php
   if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
      $uri = 'https://';
   } else {
      $uri = 'http://';
   }
   $uri .= $_SERVER['HTTP_HOST'];
   header('Location: '.$uri.'/xampp/');
   exit;
?>
Something is wrong with the XAMPP installation :-(


Good Luck
8)







ysf
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 127 guests