Page 2 of 2
Posted: Sun Dec 14, 2003 12:18 am
by vinyl-junkie
Excellent! Thanks for the link. I've still got some reading and digesting ahead of me to get where I want to go, but this is a great start. I knew if I persisted long enough, someone would be able to point me in the right direction.
Thanks again.

Posted: Sun Dec 14, 2003 2:35 am
by vinyl-junkie
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.
Posted: Sun Dec 14, 2003 2:38 am
by vigge89
oh, volka, didn't see that you asked how he did it, thought you asked how YOU do it

Posted: Sun Dec 14, 2003 4:29 am
by volka
vigge89: can't have been your fault. Obviously my question was more than just misunderstandable
Next time I will try with something like:
"In order to help you I'd like to know how exactly you have done xyz...."

Posted: Sun Dec 14, 2003 5:10 am
by Nay
Volka has been drinking Vodka

.
-Nay
Posted: Sun Dec 14, 2003 7:36 am
by volka
I should have; hot with lots of citrons. Got a bad (make that
horrible) cold

(off-topic alert....)
Posted: Sun Dec 14, 2003 10:45 am
by vinyl-junkie
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:
Code: Select all
#!/usr/bin/perl
$|=1;
print $ENV{'REDIRECT_URL'};
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:
Code: Select all
<!--#exec cgi="/GetReferer.pl" -->
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!
Posted: Sun Dec 14, 2003 10:52 am
by volka
why invoking an extra perl script only to output an environment variable?
Code: Select all
<html><body><?php echo $_SERVER['REDIRECT_URL']; ?></body></html>
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.
Posted: Sun Dec 14, 2003 11:17 am
by vinyl-junkie
Ah, well now $_SERVER['REDIRECT_URL'] works, too! But now I'm a little confused because I took that Perl script include out and I still have the bogus URL in the header!

Hmmm....
Well, I guess the important thing is, I got something to work.
Posted: Sun Dec 14, 2003 11:22 am
by vinyl-junkie
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.