Author Topic: Rewrite issue, How do I redirect users from error page to other page or link?  (Read 1570 times)

Offline ohmhyde

  • VIP Member
  • ***
  • Posts: 28
  • Karma: 4
Hi everyone.
I need you guys's professional help again.  : )
I have studied the manual about HTTP rewrite and responder but still can't figure out how to do this..

The problem is my customer, ask me to do redirect from error page for users.
It's like sometime there will be some error page from the database display to users,
Please see herefor example www.mthai.com/jib
and They want Netscaler to instead showing these pages, just redirect users to other link, or the first page.

I tried config in responder and http rewrite, still not going anywhere.
what should I use for triggering in the response policy?
and what I should use for action to redirect user to other link?
 
Please help..
I think it very easy for you guys. I just need to see the first example.. 
thanks alot guys..      :D ;D


OM K.


Offline evildani

  • Administrator
  • Hero Member
  • *****
  • Posts: 389
  • Karma: 22
Some questions first:
The error page will be the same allways? Or each URL will be the same but the content will display the error instead?
Why do you want to use rewrite?

Dani

Offline ohmhyde

  • VIP Member
  • ***
  • Posts: 28
  • Karma: 4
Thanks Dani.
The error page won't be exactly the same everytime, but there is a pattern.
Always like this but switch pattern...
////////////////////////////////this is   error page ////////////////////////////////////////////////////////////////////////////////
Warning: include(../include/function.php) [function.include]: failed to open stream: No such file or directory in /home/www/mthai/htdocs/jib/index.php on line 3

Warning: include() [function.include]: Failed opening '../include/function.php' for inclusion (include_path='.:/usr/lib/php') in /home/www/mthai/htdocs/jib/index.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/www/mthai/htdocs/jib/index.php:3) in /home/www/mthai/html/include/mthai.inc.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/www/mthai/htdocs/jib/index.php:3) in /home/www/mthai/html/include/mthai.inc.php on line 3

Warning: include(/include/mthai-lib.inc.php) [function.include]: failed to open stream: No such file or directory in /home/www/mthai/htdocs/jib/index.php on line 5

Warning: include() [function.include]: Failed opening '/include/mthai-lib.inc.php' for inclusion (include_path='.:/usr/lib/php:/home/www/mthai/html/include') in /home/www/mthai/htdocs/jib/index.php on line 5

Fatal error: Call to undefined function isAdmin() in /home/www/mthai/htdocs/jib/index.php on line 10

////////////////////////////////   error page ////////////////////////////////////////////////////////////////////////////////

and the URL won't be the same either..., it will depends on the object they call for the database...

URL rewrite?  I am not sure, one of Citrix guy told me to try to use this...   :  )

Could it be like  if we see response that contains  Fatal error ,  warning in the body or something  or  object moved 301,
we would redirect user to their main page.  or should it be Content Switching??

Just let me know what I should use in Netscaler for this, could be any feature....

Thanks  in advfance.....

OM K.

Offline evildani

  • Administrator
  • Hero Member
  • *****
  • Posts: 389
  • Karma: 22
Ok, I undestand now.

When the website is down (DB for example) and you get all those error in the page but the browser tries to load them....
tricky....
So the entire web response should be rewriten, all headers removed, the status code replaced and the location header added.
Pushing HTTP violations to a limit I would add the location header and replace the status code. That way I think the browser should follow the redirect. I am a little concerned about the body, will the page browser load it? drop it? no idea...

Let me run a test on that...
I am going to take a valid response (200 OK) and turn it into a 302.

Offline evildani

  • Administrator
  • Hero Member
  • *****
  • Posts: 389
  • Karma: 22
Try this, it worked on version 9 with mozilla FF:

add rewrite action add_location insert_http_header Location "\"http://www.google.com\""
add rewrite action status_200_to_302 replace HTTP.RES.STATUS "\" 302 Moved Temporarily\""
add rewrite policy contains_php_error "HTTP.RES.BODY(1000).CONTAINS(\"Warning: include\")" status_200_to_302
add rewrite policy contains_php_error_2 "HTTP.RES.BODY(1000).CONTAINS(\"Warning: include\")" add_location
add rewrite policy jumpto_redir true NOREWRITE
add rewrite policylabel rw_200_to_302 http_res
add rewrite policylabel "response-redirect" http_res
bind rewrite policylabel "response-redirect" contains_php_error 10 NEXT
bind rewrite policylabel "response-redirect" contains_php_error_2 20 NEXT
bind rewrite global jumpto_redir 10 NEXT -type RES_DEFAULT -invoke policylabel "response-redirect"



Offline ohmhyde

  • VIP Member
  • ***
  • Posts: 28
  • Karma: 4
 ;) Thankss..!!  Evidani
you answer looks very good.
I will test this right now.

Thanks (God)dani........   ;D   

OM K.