Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] Can I make a subdirectory of localhost behave like a root directory for a site?



TLUG,

I have a few web sites that I maintain, and do various editing and whatnot on my home machine.

The basic set up at home is that the files for each web site are in their own directory within my /var/www/ directory, like so:

/var/www/website_one/index.php
/var/www/website_two/index.php

When I want to access them through my local Apache server, I can get there with:

http://localhost/website_one/
http://localhost/website_two/

So far so good.

But what I've discovered is that when working with PHP, and linking to subdirectories and parent directories, it can get a little confusing.

For example, if I'm in http://localhost/website_one/subdirectory/, and I want to go to the root directory, I can't simply type in <a href="/">link</a>. If I do, then the link will take me to http://localhost, which is too far down.

On the other hand, I can't make the link <a href="/website_one">link</a>, because if I do, then when I upload the files to hosting service where they are actually served to the internet, the directories won't match anymore.

What I'd like to be able to do is make it so that on my local machine, when accessing each web site's directory, the server behaves as if the web site's own directory is it's root directory. Then I can test at home and upload to my hosting service without having relative links break on me.

Is this possible in any way?

ï--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links