Document root

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

Document root

Postby pcs800 » 07. September 2007 03:14

After installing xampp, my document root is C:\xampp\htdocs. So say I place a folder in C:\xampp\htdocs called web, which will house my web site, how do i get mydomain.com to default to C:\xampp\htdocs\web\
There is an index.php in there that forwards localhost to the xampp folder inside the htdocs folder.
Or am i supposed to remove that index.php and put my site in C:\xampp\htdocs
pcs800
 
Posts: 33
Joined: 22. September 2005 15:08

Postby Wiedmann » 07. September 2007 14:51

Or am i supposed to remove that index.php and put my site in C:\xampp\htdocs

That's one solution. (you don't need this index.php or files in this dir for anything...)

how do i get mydomain.com to default to C:\xampp\htdocs\web\

Or you can change the DocumentRoot setting in "httpd.conf".
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

re

Postby pcs800 » 07. September 2007 20:11

I tried changing the document root in "httpd.conf" but it seemed to mess things up. I am about as confident with editing that file as I am jumping out of a plane.

It seems when I change the documentroot, it messes up the xampp control panel web interface.

Do I need to change where it looks for php or mysql or something?
pcs800
 
Posts: 33
Joined: 22. September 2005 15:08

re

Postby pcs800 » 08. September 2007 20:50

I just need one web site on this server, apache will hosts multiple, so I am missing soimething. Someone please tell me how I can have a "webs" folder under the htdocs folder and make it the default web site.
pcs800
 
Posts: 33
Joined: 22. September 2005 15:08

Postby Izzy » 09. September 2007 00:27

http://www.apachefriends.org/en/faq-xam ... #startpage
http://www.apachefriends.org/en/xampp-windows.html#1168

In a default installation:
http://localhost/
Finds the
xampp\htdocs\index.php
and loads the Welcome to XAMPP page via a redirection in the index.php code to
xampp\htdocs\xampp\index.php

Typing this does the same thing except bypasses the first
xampp\htdocs\index.php
and opens the index.php in the xampp subdirectory
http://localhost/xampp/

If you put your web site in
xampp\htdocs\webs\
and then you type
http://localhost/
you will see the Welcome to XAMPP page just as before.
Your site in the webs directory is not known yet as the default site to the server.

If you type
http://localhost/webs/
Then your web site's index page will be displayed but not as the default site.

As Weidmann pointed out, if you remove or rename the files already in the directory
xampp\htdocs
and place your own index page complete with a redirection to the web site index page in
xampp\htdocs\webs
then type
http://localhost/
you will see your web site's index page (as in the Welcome to XAMPP scenario).
It has now become the default web site.

If you place all your web site files including your site's main index file and all sub directories of your web site into the
xampp\htdocs
directory and type this
http://localhost/
You will see your web site as the default site (but with no need for a redirect).

The Welcome to XAMPP page is still available by typing
http://localhost/xampp/

All you have done in effect is replace the default Welcome to XAMPP web site with your own web site as the default.

Using the above method does not entail changing any configuration files, at this stage, from the defaults.
So if you changed anything I suggest your revert to the original httpd.conf file.


The other method mentioned entails editing the xampp\apache\conf\httpd.conf file.

All your web site files should be in the directory
xampp\htdocs\webs

1.
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:/xampp/htdocs"
to
DocumentRoot "C:/xampp/htdocs/webs"

2.
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/xampp/htdocs">
to
<Directory "C:/xampp/htdocs/webs">


BTW
Always make a backup copy of any original conf files before editing them so you have good copies if you ever have to revert.

Always restart Apache if you do make any changes in any conf files to have those changes recognized by the server.
HTH

=================================================
Take a look at the new DeskTopXampp launch control for XAMPP and XAMPPlite (DTX.exe)
http://nat32.com/dtx/
posted by ridgewood:
http://community.apachefriends.org/f/viewtopi ... 967#103967
Also available here: http://zedfiles.com/DTX/
I highly recommend DTX.
=================================================
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby Boulle » 09. September 2007 21:49

Hello guys!! My first post here and already it's a question. Ok, call me a noob, wich i am by the way. At least when it involves these things, but i'm willing to learn.
The problem i am faced with is this;

As Weidmann pointed out, if you remove or rename the files already in the directory
xampp\htdocs
and place your own index page complete with a redirection to the web site index page in
xampp\htdocs\webs
then type
http://localhost/
you will see your web site's index page (as in the Welcome to XAMPP scenario).
It has now become the default web site.


Now, how do i place my own index page complete with a redirection to the web site index page in
xampp\htdocs\webs??

That's my question for now. Google wasn't much of a help for me at the moment. Maybe you guys are!!

Can anybody tell me how to do this??
Thx in advance!!

Greetz!
Boulle
 
Posts: 2
Joined: 09. September 2007 20:40
Location: Antwerp, Belgium

Postby Izzy » 10. September 2007 00:27

If I understand your question correctly Boulle, you can't find an answer on Google about how to create an index.* page in xampp\htdocs directory that will redirect to your index.* page in the xampp\htdocs\webs directory.

I have based this reply on that assumption.


There are many ways to redirect from one web page to another depending on your particular needs.

Seethis link orthis link for several methods with examples.

You could do no worse than to edit the contents of the XAMPP index.php in your text editor to reflect your webs directory, after renaming the original to say index.php_orig, then save your edited version as index.php.

From this:
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 :-(
to this will work:
Code: Select all
<?php
   if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
      $uri = 'https://';
   } else {
      $uri = 'http://';
   }
   $uri .= $_SERVER['HTTP_HOST'];
   header('Location: '.$uri.'/webs/');
   exit;
?>

That would redirect, as it does for XAMPP, to your index page in the webs directory using http:// or https:// (https will give you a certificate authentication error in your browser as the certificate is in the XAMPP name).

To use HTTP instead of php you could use ameta refresh tag in your index.html page in the xampp\htdocs directory after deleting or renaming the original XAMPP index.php.
This goes in between the <head></head> tags of your index.html page.
This method might be fine on localhost but often causes issues out in the Internet.

Code: Select all
<meta http-equiv="refresh" content="2;url=http://localhost/webs/">

content="0;url=http://localhost/webs/"
The number is the time, in seconds, until the page should be redirected.
Then, separated by a semi-colon (;) is the URL that should be loaded.
Use 0 (zero) seconds if you want the redirection to be instant.

Check out the other methods in the links at the top of this reply.

For serving multiple web sites from the XAMPP server you would need to research the <VirtualHost> directive or vhosts which has been covered in detail in this place, search in the XAMPP for Windows forum and/or you can read the Apache Documentation here:
http://httpd.apache.org/docs/2.3/vhosts/
http://httpd.apache.org/docs/2.3/mod/co ... irtualhost
http://httpd.apache.org/docs/2.3/vhosts/examples.html
HTH

=================================================
Take a look at the new DeskTopXampp launch control for XAMPP and XAMPPlite (DTX.exe)
http://nat32.com/dtx/
posted by ridgewood:
http://community.apachefriends.org/f/viewtopi ... 967#103967
Also available here: http://zedfiles.com/DTX/
I highly recommend DTX.
=================================================
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby Boulle » 10. September 2007 19:41

Izzy, thanks alot!!!! That explains alot for me!!! It shows me that i was thinking in the right direction last night, but i couldn't figure it out.
Youre explanation plus code will help solve the problem. Also i have learned that is is a index page that i was looking for on google....(how to make one) I'm not going to tell the keywords i've been entering.... :oops: :oops: :oops:

But i came here to learn, and that's what i will do!!

Thx again, you've been a great help!!

C y'all later!!

Greetz!!
Boulle
 
Posts: 2
Joined: 09. September 2007 20:40
Location: Antwerp, Belgium

re

Postby pcs800 » 10. September 2007 19:44

yes, thanks for explaining. It is what I had already tried, but somehow I had messed up xampps config page (php pointers were all complaining). But I have it now, thanks and have a great day.
pcs800
 
Posts: 33
Joined: 22. September 2005 15:08


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 32 guests