Forum Moderators: coopster & phranque

Message Too Old, No Replies

The file location

I need some help.

         

adni18

11:01 pm on Nov 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there a way to determine what the current file location is? (I need this for an error message, to determine what the file is that the user tried to access.)

jollymcfats

11:54 pm on Nov 10, 2004 (gmt 0)

10+ Year Member



For CGI, the script name can be found in
$0
, or the URI to it in
$ENV{'SCRIPT_NAME'}
. $0 might bork if you're running mod_perl, I don't recall.

There's also

__FILE__
, a magic constant which is the full path to the file in which it is literally written.

print "This print is in file " . __FILE__ . "\n";

adni18

11:59 pm on Nov 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, I am using an error page, and whenever I access the error page, the address bar shows /error.cgi . Will this script get the page the user was trying to access?

jollymcfats

12:09 am on Nov 11, 2004 (gmt 0)

10+ Year Member



An error page like a custom 404 or error page?

Take a look in

$ENV{'REQUEST_URI'}
, that should contain the original URL that was requested.

adni18

1:40 am on Nov 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks.

adni18

11:49 pm on Nov 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I still get the location of the error file, and not the requested file, when I use $ENV{'REQUEST_URI'}. I get /error.cgi instead of /games/chooser/invalid.html