Variable in Document Root?

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Variable in Document Root?

Post by spacebiscuit »

Hi,

I am setting up a virtual host within Apache as follows:

DocumentRoot "c:/Apache2/htdocs/mysite/index.php?data=1"

When I open the domain in my browser it does open the correct index.php page but I cannot read the variable data. Is what I am attempting possible?

Thanks in advance,

Rob.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Variable in Document Root?

Post by VladSun »

:)
You can't use DocumentRoot for such purposes.
DocumentRoot must be a valid path (i.e. directory, not a file).
Also, index.php is viewed not because of the DocumentRoot value, but because your DirectoryIndex directive is set so.
There are 10 types of people in this world, those who understand binary and those who don't
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Variable in Document Root?

Post by spacebiscuit »

Hmm, interesting.

This is my directory index line:

DirectoryIndex index.php index.html index.htm index.html.var

If I set the Documentroot as follows:

DocumentRoot "d:/Apache2/htdocs/mysite/home.php"

I get page canot be displayed unless I place a file named home.php in the root, which implies it does look for the named file and not just the directory.

Regarding the variable, I have found another method. I am using

Code: Select all

$_SERVER['HTTP_HOST']
...to check for the domain name and i'm then setting the variable accordingly.

Thanks,

Rob.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Variable in Document Root?

Post by VladSun »

http://httpd.apache.org/docs/2.0/mod/co ... cumentroot
Description: Directory that forms the main document tree visible from the web
Syntax: DocumentRoot directory-path
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply