interesting situation:
OS: Windows
Server: Apache 1.3.29
Modified ErrorDocument 404 to point to a redirect.pl script in cgi-bin
http.conf
ErrorDocument 404 /cgi-bin/redirect.pl
redirect.pl
sub DO_REDIRECT {
...
print "Location: /index.html \n\n";
...
}
this works when I access the script directly by its url.
but when its forwarded to by the 404 error it does not work.
Any one has any idea how to make it work, please reply.
Additional Info ... :
I tried printing out the headers manually but it does not work.
lets say: http://yourdomain.com/some_nonsensical_stuff_here
Here are some headers from the 404 redirect:
GET /some_nonsensical_stuff_here HTTP/1.1
-server headers-
HTTP/1.z 404 Not Found
Server: Apache/1.3.29 (Win32)
Location: http://yourdomain.com/index.html
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/plain
The header from accessing the url directly are a bit different:
GET /index.html HTTP/1.1
-server headers-
HTTP/1.z 200 OK
Server: Apache/1.3.29 (Win32)
Etag: "0-5d6-3af1f126"
Accept-Ranges: bytes
Content-Length: 1494
Content-Type: text/html
|
|
0
|
|
|
|
Reply
|
goodwill4 (2)
|
11/30/2003 4:35:43 AM |
|
Please note that your question is totally off topic in this group.
Will wrote:
>
> redirect.pl
> sub DO_REDIRECT {
> ...
> print "Location: /index.html \n\n";
> ...
> }
>
> this works when I access the script directly by its url.
> but when its forwarded to by the 404 error it does not work.
I would try the full URL instead of just /index.html.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
|
|
0
|
|
|
|
Reply
|
Gunnar
|
11/30/2003 4:37:52 AM
|
|
On Sun, 29 Nov 2003, Will wrote:
> interesting situation:
Would be on-topic for comp.infosystems.www.authoring.cgi
> print "Location: /index.html \n\n";
Check the CGI specification. That form of CGI response is mandated to
return its results with status 200 (sometimes known as an internal
redirection).
To get a redirection by means of an external HTTP redirection
transaction (HTTP status 30x and HTTP location header), the CGI
specification calls for a complete URL in the CGI Location: response.
> Any one has any idea how to make it work, please reply.
Perlfaq9 points you at appropriate resources (and the appropriate
newsgroup for discussing the topic). Use the FAQs, Luke.
|
|
0
|
|
|
|
Reply
|
Alan
|
11/30/2003 12:37:10 PM
|
|
Using full url, does not work either.
The redirect script works fine if it is not forwarded to by ErrorDocument 404
I think the problem is in that the page already has header
HTTP/1.z 404 Not Found
I tried overwriting that but so far no luck.
I've read up on perlfaq9 and other, so far no clue.
What group should I post it in?
It seems like since I am writing it in perl: comp.lang.perl.misc
|
|
0
|
|
|
|
Reply
|
goodwill
|
12/2/2003 2:12:08 AM
|
|
> Check the CGI specification. That form of CGI response is mandated to
> return its results with status 200 (sometimes known as an internal
> redirection).
yes, but if the script is pointed to by ErrorDocument 404 the header
is 404.
>
> To get a redirection by means of an external HTTP redirection
> transaction (HTTP status 30x and HTTP location header), the CGI
> specification calls for a complete URL in the CGI Location: response.
>
I tried adding an addition header 30x or 200 along with location
header but it just does not work. My guess would be I would have to
modify the original top
HTTP/1.z 404 Not Found header. I am not really sure how.
>
> Perlfaq9 points you at appropriate resources (and the appropriate
> newsgroup for discussing the topic). Use the FAQs, Luke.
Read them all before, can not find a solution yet.
Where would I post this. this is a perl group.
|
|
0
|
|
|
|
Reply
|
goodwill
|
12/2/2003 2:28:37 AM
|
|
On Tue, 1 Dec 2003, Will wrote:
> > Check the CGI specification. That form of CGI response is mandated to
> > return its results with status 200 (sometimes known as an internal
> > redirection).
>
> yes, but if the script is pointed to by ErrorDocument 404 the header
> is 404.
I'd overlooked that detail of the original problem, yes. Sorry.
An external redirection will still need status 30x, though.
> I tried adding an addition header 30x or 200 along with location
> header but it just does not work.
That looks like a classic case of what the posting guidelines warn
against. You haven't said precisely what you did, and you haven't
said precisely what you hoped would happen, and you haven't said what
you found did happen. "it just does not work" sets off all the alarm
bells here.
[detail omitted]
> > Perlfaq9 points you at appropriate resources (and the appropriate
> > newsgroup for discussing the topic). Use the FAQs, Luke.
>
> Read them all before, can not find a solution yet.
>
> Where would I post this.
On the group suggested by perlfaq9 (if you can get past the group's
automoderation bot).
Or maybe on the relevant comp.infosystems.www.servers.* group, if this
is in fact an issue with the ErrorDocument configuration rather than
being a specifically CGI issue.
> this is a perl group.
Yes.
|
|
0
|
|
|
|
Reply
|
Alan
|
12/2/2003 11:01:13 AM
|
|
It occurs to me that the good Will either solved this one himself, or
took fright at the response on c.l.p.misc; anyway I'm taking the
initative of deciding that this was more of a server issue than a
specifically CGI one, though I could turn out to have been mistaken...
Interested parties could perhaps read the start of the thread on
c.l.perl.misc, or at
http://groups.google.com/groups?selm=c97890a4.0311292035.63b7b660%40posting.google.com
but in brief the questioner wanted to:
- define an errordocument 404 which invoked a CGI script;
- have the CGI script issue some flavour of "Location:" response.
In its original form, his "Location:" response was specifying an
absolute virtual path...
[I had said:]
> > Check the CGI specification. That form of CGI response is mandated to
> > return its results with status 200 (sometimes known as an internal
> > redirection).
I was forgetting of course that there was a 404 status from the
original error. "now read on..."
On Tue, 1 Dec 2003, Will wrote:
> yes, but if the script is pointed to by ErrorDocument 404 the header
> is 404.
OK: required reading at this point (you mentioned apache 1.3.*)
would be http://httpd.apache.org/docs/mod/core.html#errordocument
and http://httpd.apache.org/docs/custom-error.html
As you see, in the situations described there, a reference to an
absolute URLpath ("local URL" as the apache doc puts it) is able to
preserve the original error code, which is normally what one wants.
Whereas, if you succeed in creating an external redirection, then the
original 404 error code will go missing. What actually were you
hoping to achieve in terms of a status code?
In the event, in your original posting, you show that what you got
when the script issued a "Location: /absURLpath" response, was an
error status 404 (from the original error) plus a Location: HTTP
header, which isn't at all what you hoped.
[I had gone on to say:]
> > To get a redirection by means of an external HTTP redirection
> > transaction (HTTP status 30x and HTTP location header), the CGI
> > specification calls for a complete URL in the CGI Location: response.
but of course -if- one does that, then the original 404 status goes
missing, just as it says in the documentation.
> I tried adding an addition header 30x or 200 along with location
> header but it just does not work. My guess would be I would have to
> modify the original top
> HTTP/1.z 404 Not Found header. I am not really sure how.
I have to admit at this point I drew a blank: I'm not quite sure what
you want as the final outcome of this, and also I'm not sure what
Apache is meant to do in this specific scenario - it doesn't seem to
be documented. That's where I decided that it was more in the nature
of an Apache question than a CGI question, hence the cross-posting and
followups set.
hope this helps to move the discussion forward a bit.
|
|
0
|
|
|
|
Reply
|
Alan
|
12/4/2003 1:22:28 AM
|
|
|
6 Replies
36 Views
(page loaded in 2.324 seconds)
Similiar Articles: input & output in assembly - comp.lang.asm.x86; 0x0010 Agressively trim working set ... by default, but this may be "redirected" using ... simpler for the novice who has already learned his native tools to continue using ... Sampling: What Nyquist Didn't Say, and What to Do About It - comp ...(for an example of NOT using high ... the next project (that is already ... In that distro they redirected all error messages to /dev/zero, > so if something did not work you ... PHP: header - Manual... redirected in about 5 secs. If not, click here." you cannot use header( 'Location ... redirects, so if you are using header(Location ... not working because of the "header already ... Recommendations for Folder Redirection: Group PolicyDo not use the Redirect to home folder policy setting unless you have already ... This redirection option does not work ... are not copied to the redirected location ... 7/30/2012 10:55:27 AM
|