Thanks again.
What page sent 'em to 404.php?
Moderator: General Moderators
- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
OK, I've read the page you posted the link for, checked some other places and generally studied this whole question area. I'm still a bit confused though.
On that page you gave the link for, where it says:
"To achieve this, Apache will define new CGI-like environment variables:"
and then goes on to list some commands, does all that stuff need to go into my .htaccess file? Or just the variables I need, like:
REDIRECT_QUERY_STRING=
?
If I need to put that whole thing into my .htaccess file, how do I find what those values should be? I have a phpinfo() script on my server, but I'm not certain as to which variables from that are used.
I think I can bluff my way through the Perl script once I get the above questions answered.
On that page you gave the link for, where it says:
"To achieve this, Apache will define new CGI-like environment variables:"
and then goes on to list some commands, does all that stuff need to go into my .htaccess file? Or just the variables I need, like:
REDIRECT_QUERY_STRING=
?
If I need to put that whole thing into my .htaccess file, how do I find what those values should be? I have a phpinfo() script on my server, but I'm not certain as to which variables from that are used.
I think I can bluff my way through the Perl script once I get the above questions answered.
- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
Um, to redirect this thread back to the original topic..
I have no idea just how I did it (
), but I had I had this coded correctly after all. I was looking for something in the body of my 404 page, but what the Perl script does, I guess, is preserve the original header URL that was there prior to redirecting to the 404 page. (Does that make sense?)
I'll see if I can document how I did this so it's understandable.
(1) Put an error document statement in your .htaccess like this:
ErrorDocument 404 /404.php
(2) Created a Perl script (GetReferer.pl) to be used in 404.php. The script looks like this:
Note that your path to Perl may be different from mine. Check with your web host on that.
(3) Imbedded the Perl script in my 404.php page like so:
The Perl script goes somewhere within the <body></body> tags. Note that the path to your Perl script may be different than mine, if your web host uses a cgi-bin. Check with your web host on where you should place Perl or CGI scripts.
That's it!
I have no idea just how I did it (
I'll see if I can document how I did this so it's understandable.
(1) Put an error document statement in your .htaccess like this:
ErrorDocument 404 /404.php
(2) Created a Perl script (GetReferer.pl) to be used in 404.php. The script looks like this:
Code: Select all
#!/usr/bin/perl
$|=1;
print $ENV{'REDIRECT_URL'};(3) Imbedded the Perl script in my 404.php page like so:
Code: Select all
<!--#exec cgi="/GetReferer.pl" -->That's it!
why invoking an extra perl script only to output an environment variable?
If this one doesn't work but the perl script does ...well, i'd call that rather spooky.
Might be you have to replace $_SERVER by $_ENV. But that's why I asked wether php is installed as module or as cgi.
Code: Select all
<html><body><?php echo $_SERVER['REDIRECT_URL']; ?></body></html>Might be you have to replace $_SERVER by $_ENV. But that's why I asked wether php is installed as module or as cgi.
- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
Oh, wait. I think I just solved the mystery. In my .htaccess file, I had the full http address in the ErrorDocument statement earlier and had changed it to a relative path. I seem to recall that the server variables don't get picked up when you have the full http address. I'm pretty sure that's what made the difference.