Retrieving client URL and formatting a URL


#1

Hey, two questions… (Sorry if its a little long winded, but I didn’t want to confuse anyone)

I’ve got a slight problem with my server and its custom error page handling. When someone visits an invalid entitiy (directory or page) or attempts to view a directory without an index page the request is “silently” redirected to a custom script. (ie, a 403/404 custom error page)

Now I’ve coded it to check a couple of items from the client and see whether or not that user is local (ie, on the local network or VPN), if the user is on the network it’ll display the contents of that directory.

However, the script outputs the directory details as if you had visited the error script directly…

ie…

you visit http://server/home/files
it’ll say “ok directory doesn’t have an index, directory viewing is disabled… show custom error”

it then loads the following page
http://server/error/errorscript.php

for some reason the script doesn’t pickup that its placeholder and assumes you visted it directly. If you try and use the directory handling tools it’ll display “.” as http://server/error/… Opposed to the correct directory of http://server/home/files.

So basically, how do I get the script to pickup the directory the user visited?

(Just to clear up, it doesn’t actually redirect the user, rather it’ll serve up the error page instead of it)

second question…

How can I get just the directory path from $PHP_SELF (ie cut a string down dynamically stopping at a perticular charater)

ie
http://home/folder/files/image.php
to
http://home/folder/files/

Thanks a lot guys,
Miles