Hi Hossein,

thanks for that info - that was very helpful. I was looking at some code that 
called ns_returnerror. Now I need to dig into why it does what it does as I can 
see now it just may be calling the wrong thing.

By the way, I'm a HUGE fan of your website. Well done!! I never noticed it was 
running on AOLserver before. :-)

Brian

________________________________________
From: AOLserver Discussion [aolser...@listserv.aol.com] On Behalf Of Hossein 
Sharifi [shar...@rateyourmusic.com]
Sent: 01 March 2010 14:51
To: AOLSERVER@listserv.aol.com
Subject: Re: [AOLSERVER] ns_returnerror 404 and redirects

Hi Brian,

Here's how I understand it to work (anyone with more expertise is welcome to 
chime in).

First of all, the redirects in the config file are only used when:
  1) nsd handles the relevant case directly (for example, a user requests a 
file that doesn't exist and nsd handles it, using your specified 404 redirect).
  2) you explicitly call an error proc that is directly related to the error in 
question.  For example, you handle the "not found" case in your TCL code and 
call ns_returnnotfound.  You can use ns_returnforbidden to return a 403, 
ns_returnunauthorized for a 401, etc.  A full list is at 
http://panoptic.com/wiki/aolserver/Ns_return

Secondly, the purpose of ns_returnerror is more specific than it might seem at 
first.  The purpose of that proc is to return a generic "Request Error" page 
that wraps the error string that you pass in.  It's generally used in the error 
cases that do not match any of the predefined errors (like filenotfound), but 
you don't have to use it at all if you don't want; you can just use ns_return 
with the appropriate status code if you want to specify exactly what is 
returned.

So in summary, if you want AOLserver to redirect based on what you've specified 
in the config file, you must call the specific ns_return function that's 
related to the type of error.   Although ns_return  and ns_returnerror can be 
used to return error-related HTTP status codes to the browser, they do not 
utilize the redirects in the config file.

Regards
Hossein


On Mon, Mar 1, 2010 at 10:12 AM, Fenton, Brian 
<brian.fen...@quest.ie<mailto:brian.fen...@quest.ie>> wrote:
Hi Hossein

thanks for replying. Sorry, I should have said that it's not just happening 
with 404s. I tested it with all of the status codes below and none of them 
redirect. So is it the case that you should only use ns_returnerror with status 
codes not in the "redirects" parameter list? I'm a little confused.

ns_section ns/server/${server}/redirects
   ns_param   404                "/global/file-not-found.adp"
   ns_param   403                "/global/forbidden.html"
   ns_param   500                "/global/error.adp"
   ns_param   503                "/global/error.adp"
   ns_param   505                "/global/error.adp"

thanks for the help
Brian

________________________________________
From: AOLserver Discussion 
[aolser...@listserv.aol.com<mailto:AOLSERVER@LISTSERV.AOL.COM>] On Behalf Of 
Hossein Sharifi [shar...@rateyourmusic.com<mailto:shar...@rateyourmusic.com>]
Sent: 26 February 2010 17:54
To: AOLSERVER@LISTSERV.AOL.COM<mailto:AOLSERVER@LISTSERV.AOL.COM>
Subject: Re: [AOLSERVER] ns_returnerror 404 and redirects

In most cases, you should use ns_returnnotfound to return a 404 error.   I'm 
pretty sure that the behavior of ns_returnerror is correct and expected.

On Fri, Feb 26, 2010 at 6:31 PM, Fenton, Brian 
<brian.fen...@quest.ie<mailto:brian.fen...@quest.ie><mailto:brian.fen...@quest.ie<mailto:brian.fen...@quest.ie>>>
 wrote:
Hi

I'm looking at using the 404 redirects in AOLserver. There was a recent bug 
fixed in 4.5.1. where 404s were not redirecting to the config file value e.g.

ns_section ns/server/${server}/redirects
  ns_param   404               "/global/file-not-found.adp"

This works great now when I try to access a page that doesn't exist - it 
redirects nicely to "/global/file-not-found.adp". However, when I make a call 
to ns_returnerror with a 404 from within a .tcl page, it doesn't redirect to 
"/global/file-not-found.adp" e.g.

ns_returnerror 404 "This is some error text"

gives me a page saying "Request Error" followed by the text I supplied to 
ns_returnerror.

Is this expected behaviour i.e. a feature or a bug?

thanks
Brian


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
<lists...@listserv.aol.com<mailto:lists...@listserv.aol.com><mailto:lists...@listserv.aol.com<mailto:lists...@listserv.aol.com>>>
 with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.



--
Hossein Sharifi
http://rateyourmusic.com





--
AOLserver - http://www.aolserver.com/



To Remove yourself from this list, simply send an email to 
<lists...@listserv.aol.com<mailto:lists...@listserv.aol.com>> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
<lists...@listserv.aol.com<mailto:lists...@listserv.aol.com>> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.



--
Hossein Sharifi
http://rateyourmusic.com





--
AOLserver - http://www.aolserver.com/



To Remove yourself from this list, simply send an email to 
<lists...@listserv.aol.com> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
<lists...@listserv.aol.com> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to