Forum Moderators: coopster

Message Too Old, No Replies

HTTP_Referer

Help.

         

mipapage

7:22 pm on Nov 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm looking at writing a PHP 404 page for a site whose pages may change faster than google can update it's listings.

I was hoping to extract the search terms from the http_refererere and do some fancy error handling by providing the user with alternatives to the 'now-defuct-page' (similar in fasion to php.net).

Problem is, my provider tells me that 'I'd suggest putting up a generic 404 that redirects to your custom php based 404'. I'm assuming that I'd use a meta-redirect for this, which means that I would lose the httttp_referere data, no?

Is there some way around this?

NickCoons

7:45 pm on Nov 5, 2003 (gmt 0)

10+ Year Member



mipapage,

Why would your provider recommend this to you?

I don't know about other web servers, but with Apache you can setup a custom 404 page that is displayed in lieu of the standard 404 error message. This way, as long as the page is on the local file system and not referred to with [,...] then you won't lose the environment variables.

If you, however, have the 404 page redirect to yet another page (as it sounds like your provider is recommending), then you will lose those variables.. so I wouldn't do it that way.

mipapage

7:55 pm on Nov 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey NickCoons,

thanks for the swift reply!

My provider has it set up so that there is an error 'directory', and in that directory you need to put a '404'.'whatever is allowed'. Apparently PHP isn't allowed.

I'm asking him if I can use the .htaccess ErrorDocument method.

then you will lose those variables

That's what I feared...

jatar_k

10:07 pm on Nov 5, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you could also do 404.html and make .html php parsed.

mipapage

10:24 pm on Nov 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you could also do 404.html and make .html php parsed.

Is this something that I can do without harassing my provider? (something tells me this is a php.ini thing, or of course, httpd.conf...)

NickCoons

11:22 pm on Nov 5, 2003 (gmt 0)

10+ Year Member



mipapage,

<Is this something that I can do without harassing my provider?>

You should be able to do just about anything like this in .htaccess as long as your provider has allowed it. So to answer your question.. No, you're probably going to have to harass him again :-).

If only HTML is allowed, I wonder if you could do some sort of JavaScript redirection, and have the JavaScript resubmit all of the values (like HTTP_REFERER) that you're looking for. This is not a good way to go.. but it might be an only option.

mipapage

11:36 pm on Nov 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks again,

My provider is generally pretty good about letting me at the .htaccess file, so I would imagine that this will work out... Now though, on to the next step - building the PHP!

Timotheos

11:54 pm on Nov 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might also be able to put your own .htaccess in the specific directory and then you won't have to bother with the main one. Of course, this is also dependant on your provider.