Reply
Employee
owen
Posts: 213
Registered: 09-14-2011
0

Re: HTTP response codes: redirects and 404's traffic script

Another option is to use the TrafficScript http.sendResponse() function to control how the 404 content is sent to the client:

http.sendResponse"404 Not Found", "text/html"$body, "");
You'll need to fill $body with the content of your 404 message; either put it inline in your trafficscript rule, or pull it out of the 'extra files' store using resource.get().

 

Fry
rudolph
Posts: 2
Registered: 11-01-2011
0

Re: HTTP response codes: redirects and 404's traffic script

Thanks for the response Edwin. I wll give the Java option a go.

 

Moderator
Edwin Groothuis
Posts: 381
Registered: 10-19-2008
0

HTTP response codes: redirects and 404's traffic script

With any knowledge of the system itself:

If you redirect in the HTTP header, the response code is 302. You will get a 200 later because the file you get redirected to exists.

If you want to keep the 404 on the first response you will need to use some JavaScript in the HTTP body to do the redirection.

Edwin


Edwin
--
Edwin Groothuis - Riverbed Support

If this answered your question, please click "Accept as Solution" ------->
Fry
rudolph
Posts: 2
Registered: 11-01-2011
0
Accepted Solution

HTTP response codes: redirects and 404's traffic script

I have the following script to redirect a server 404 responses to a nice 404_error.htm page:

 

ifhttp.getResponseCode(!= 404 break;
http.setResponseCode("404 Not Found");
http.redirect"/404_error.htm" )

 

The problem is that the script returns a 302 and then a 200 in http watch. I would like to see at 404 repose code returned before the redirect takes place.

 

Line two of the rule does not have the desired effect, it seems that I could either do a 404 or a 302. Is there a way of combining the two?

 

‬‪‬‪‬‪