What page sent 'em to 404.php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
vinyl-junkie
Forum Newbie
Posts: 23
Joined: Sat Nov 22, 2003 2:52 pm
Location: Seattle, WA area (USA)

Post 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. :D
User avatar
vinyl-junkie
Forum Newbie
Posts: 23
Joined: Sat Nov 22, 2003 2:52 pm
Location: Seattle, WA area (USA)

Post 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.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

oh, volka, didn't see that you asked how he did it, thought you asked how YOU do it :D :roll:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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...." :)
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Volka has been drinking Vodka 8) 8O.

-Nay
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I should have; hot with lots of citrons. Got a bad (make that horrible) cold ;)
(off-topic alert....)
User avatar
vinyl-junkie
Forum Newbie
Posts: 23
Joined: Sat Nov 22, 2003 2:52 pm
Location: Seattle, WA area (USA)

Post by vinyl-junkie »

Um, to redirect this thread back to the original topic.. :wink:

I have no idea just how I did it ( 8O ), 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!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
User avatar
vinyl-junkie
Forum Newbie
Posts: 23
Joined: Sat Nov 22, 2003 2:52 pm
Location: Seattle, WA area (USA)

Post 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! 8O Hmmm....

Well, I guess the important thing is, I got something to work.
User avatar
vinyl-junkie
Forum Newbie
Posts: 23
Joined: Sat Nov 22, 2003 2:52 pm
Location: Seattle, WA area (USA)

Post 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.
Post Reply