redirect using location header does not work from an already redirected doc.

W

Will

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
 
G

Gunnar Hjalmarsson

Please note that your question is totally off topic in this group.
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.
 
A

Alan J. Flavell

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.
 
W

Will

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
 
W

Will

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.
 
A

Alan J. Flavell

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]
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top