Jump to content

DocumentRoot & VirtualHost problems, i think.


play_

Recommended Posts

I have apache2 setup on my local machine with virtualhosts.

 

In my hosts file, i have this:

 

127.0.1.1      mysite

This just allows me to just type 'mysite' in the browser, and it servers '/media/Shared/sites/www/'

 

 

I have

echo $_SERVER['DOCUMENT_ROOT']

at the top of my index.php script.

 

If i type 'http://mysite' in my browser's url, everything loads fine(on include errors, etc). And shows that the root is '/media/Shared/sites/www/mysite'

 

If however i type http://localhost/mysite,

it shows the root as /media/Shared/sites/www

 

As you can imagine, having "2 different root dirs" causes include problems.

 

When i wanna show friends/clients something im working on, id like to link the them to http://12.345.678/mysite (which is yields same problem as http://localhost/mysite).

 

How can I fix this?

 

Don't let me down phpf =(

 

Well, you basically have 3 options:

 

-A host name.  I like no-ip.com for that, and some people like dyndns if you're looking for free solutions (and everyone knows free stuff is better :)).  If you have a personal domain with unlimited subdomains or something, you could always go that route.

 

-Have the other person edit his hosts file (and most people will not know how to do that)

 

-Do everything relative to the current folder, or use absolute paths.  The main problem with this would be images/css files/js files since /image.jpg would work on http://mysite/ but not the IP address or localhost (meaning you would have to either write a ob_start() callback function to process all the links, or have href="{$ROOT}/path" type crap everywhere.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.