So this is my directory structure
/
/test
index.php
blah.php
blah.php
So in /test/index.php I have a link such as this
<a href="/blah.php">Link</a>
but I want it to link to /test/blah.php, not the blah.php in the root directory. Basically, I want to set a local document root. Is this possible to set this using .htaccess or in the httpd.conf?
If an
atag on/test/index.phphas itshrefset to/blah.php, then it’s the browser that’s interpreting that as pointing to a file in the document root. So you can’t achieve what you want without changing the way you’re generating thehrefattribute.You have a couple of options for this:
You can omit the forward slash to generate links relative to the current URL instead of the document root. A link in
/test/index.phppointing toblah.phpwill be interpreted as/test/blah.php.You can write some custom code to generate your links. You could have a function
my_special_link ($link)that takes inblah.phpand prepends the current file’s directory, for example.