setting up subdomains in order to do root based paths
Posted: 11. April 2009 22:53
hey guys - so I've been having serious issues trying to get subdomains to work with my windows xampp installation so I can use root based paths ("\includes\header.php") as opposed to ("includes\header.php"), because using relative paths won't always work out for me (I have multiple projects, and trying to use relative paths just don't work in some situations).
My xampp installation is in "C:\users\maki\docs\xampp"
my 'public folder' is at "C:\users\maki\docs\xampp\htdocs"
and the different 'sites' I want to use as subdomains (http://site1.localhost, http://site2.localhost, etc) are also in htdocs:
C:\users\maki\docs\xampp\htdocs\site1
C:\users\maki\docs\xampp\htdocs\site2
etc..
I have followed the guide here: viewtopic.php?p=92407 to no avail.
I uncommented this line in httpd.conf:
and have these lines in httpd-vhosts.conf:
now, for site1, if I have "C:/users/maki/docs/xampp/htdocs/site1/index.php" and "C:/users/maki/docs/xampp/htdocs/site1/includes/header.php":
index.php:
this is what I get when I browse to http://site1.localhost:
HOWEVER, If I remove the "\" from the paths in the include statements, it works fine.....
I am about to just have to have each project in it's own xampp installation (have each site's contents in the root of htdocs), but I'd rather not have to have 200+mb for each site (because of the size of xampp) -- any suggestions at all???
thanks!
My xampp installation is in "C:\users\maki\docs\xampp"
my 'public folder' is at "C:\users\maki\docs\xampp\htdocs"
and the different 'sites' I want to use as subdomains (http://site1.localhost, http://site2.localhost, etc) are also in htdocs:
C:\users\maki\docs\xampp\htdocs\site1
C:\users\maki\docs\xampp\htdocs\site2
etc..
I have followed the guide here: viewtopic.php?p=92407 to no avail.
I uncommented this line in httpd.conf:
- Code: Select all
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
and have these lines in httpd-vhosts.conf:
- Code: Select all
# Default site: http://localhost
<VirtualHost *:80>
DocumentRoot "C:/users/maki/docs/xampp/htdocs/"
ServerName localhost
ServerAlias localhost
</VirtualHost>
# Foo sub domain: http://site1.localhost
<VirtualHost *:80>
ServerName site1.localhost
DocumentRoot "C:/users/maki/docs/xampp/htdocs/site1/"
DirectoryIndex index.php index.html index.html index.htm index.shtml
</VirtualHost>
now, for site1, if I have "C:/users/maki/docs/xampp/htdocs/site1/index.php" and "C:/users/maki/docs/xampp/htdocs/site1/includes/header.php":
index.php:
- Code: Select all
<p><?php echo "My location: " . dirname(__FILE__); ?></p>
<?php
include("\includes\header.php");
echo 'this is the index - realpath:' . realpath("\includes\header.php");
?>
this is what I get when I browse to http://site1.localhost:
- Code: Select all
My location: C:\users\maki\docs\xampp\htdocs\site1
Warning: include(\includes\header.php) [function.include]: failed to open stream: No such file or directory in C:\users\maki\docs\xampp\htdocs\site1\index.php on line 5
Warning: include() [function.include]: Failed opening '\includes\header.php' for inclusion (include_path='.;C:\users\maki\docs\xampp\php\pear\') in C:\users\maki\docs\xampp\htdocs\site1\index.php on line 5
this is the index - realpath:
HOWEVER, If I remove the "\" from the paths in the include statements, it works fine.....
I am about to just have to have each project in it's own xampp installation (have each site's contents in the root of htdocs), but I'd rather not have to have 200+mb for each site (because of the size of xampp) -- any suggestions at all???
thanks!