You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Ujjwal Kumar <uj...@bankbazaar.com> on 2011/09/16 08:58:56 UTC
[users@httpd] Mod Rewrite for Server Status 503, depending upon URL
I want to redirect only if there is an error (server status 503). Without
the error, this is the redirect script, which works fine:
Redirect /music http://google.com/music
Redirect /talk http://pidgin.com/some_gtalk_url
But, this redirects /music to http:// google.co/music in all cases. I want
this redirect only in case of an error. This syntax:
ErrorDocument 503 http://google.com/music
redirects all urls with 503 error message to http://google.com/music. But, I
want the /talk ones with 503 error messages to be redirected to
https://pidgin.com/some_gtalk_url
Any clues on how to do it?
Few notes on the problem:
- /music is not a physical directory
- In one sentence, the problem is to redirect specific urls (a) to a page
only if that specific url (a) has a 503 error.
- This problem is also discussed on stack overflow:
http://stackoverflow.com/questions/7387862/mod-rewrite-for-server-status-503-depending-upon-url
Ujjwal
Re: [users@httpd] Mod Rewrite for Server Status 503, depending upon URL
Posted by Ujjwal Kumar <uj...@bankbazaar.com>.
Thanks Pete. It worked perfectly!! :)
On Sat, Sep 17, 2011 at 8:25 PM, Pete Houston <ph...@openstrike.co.uk> wrote:
> Untested, but:
>
> <VirtualHost x.x.x.x:80>
> ServerName www.mysite.com
> <Location /books>
> ErrorDocument 503 http://www.mypartnersite.com/books
> </Location>
> <Location /music>
> ErrorDocument 503 http://www.mypartnersite.com/music
> </Location>
> ...
> </VirtualHost>
>
> should do what you describe.
>
> Pete
>
> On Sat, Sep 17, 2011 at 07:28:39PM +0530, Ujjwal Kumar wrote:
> > /music is not a directory, it is just a URL which is routed to some
> > specific JSP (bound with a struts action), through struts.xml and
> > urlrewrite.xml (using tuckey).
> >
> > I am restating the problem with more clarity.
> >
> > Lets say we have 2 sites www.mysite.com and www.mypartnersite.com
> > mysite deals with books, music, electronics, mobiles etc, partnersite
> deals
> > with only books and music
> >
> > In case of system errors, say 503(site unavailable) I would like to
> > automatically redirect
> >
> > www.mysite.com/books to www.mypartnersite.com/books
> > www.mysite.com/music to www.mypartnersite.com/music
> > and not do anything for
> > www.mysite.com/electronics and www.mysite.com/mobiles [ ie give out 503
> as
> > it is]
> >
> > How to set this up?
> >
>
> --
> Openstrike - improving business through open source
> http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107
>
Re: [users@httpd] Mod Rewrite for Server Status 503, depending upon
URL
Posted by Pete Houston <ph...@openstrike.co.uk>.
Untested, but:
<VirtualHost x.x.x.x:80>
ServerName www.mysite.com
<Location /books>
ErrorDocument 503 http://www.mypartnersite.com/books
</Location>
<Location /music>
ErrorDocument 503 http://www.mypartnersite.com/music
</Location>
...
</VirtualHost>
should do what you describe.
Pete
On Sat, Sep 17, 2011 at 07:28:39PM +0530, Ujjwal Kumar wrote:
> /music is not a directory, it is just a URL which is routed to some
> specific JSP (bound with a struts action), through struts.xml and
> urlrewrite.xml (using tuckey).
>
> I am restating the problem with more clarity.
>
> Lets say we have 2 sites www.mysite.com and www.mypartnersite.com
> mysite deals with books, music, electronics, mobiles etc, partnersite deals
> with only books and music
>
> In case of system errors, say 503(site unavailable) I would like to
> automatically redirect
>
> www.mysite.com/books to www.mypartnersite.com/books
> www.mysite.com/music to www.mypartnersite.com/music
> and not do anything for
> www.mysite.com/electronics and www.mysite.com/mobiles [ ie give out 503 as
> it is]
>
> How to set this up?
>
--
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107
Re: [users@httpd] Mod Rewrite for Server Status 503, depending upon URL
Posted by Ujjwal Kumar <uj...@bankbazaar.com>.
/music is not a directory, it is just a URL which is routed to some
specific JSP (bound with a struts action), through struts.xml and
urlrewrite.xml (using tuckey).
I am restating the problem with more clarity.
Lets say we have 2 sites www.mysite.com and www.mypartnersite.com
mysite deals with books, music, electronics, mobiles etc, partnersite deals
with only books and music
In case of system errors, say 503(site unavailable) I would like to
automatically redirect
www.mysite.com/books to www.mypartnersite.com/books
www.mysite.com/music to www.mypartnersite.com/music
and not do anything for
www.mysite.com/electronics and www.mysite.com/mobiles [ ie give out 503 as
it is]
How to set this up?
On Fri, Sep 16, 2011 at 9:36 PM, Mark Montague <ma...@catseye.org> wrote:
> On September 16, 2011 2:58 , Ujjwal Kumar <uj...@bankbazaar.com>
> wrote:
>
>>
>> * /music is not a physical directory
>>
>>
> What is /music? Is this URL proxied? Is the content for this URL
> generated by a script? Something else?
>
>
> * In one sentence, the problem is to redirect specific urls (a) to a
>>
>> page only if that specific url (a) has a 503 error.
>>
>>
> The easiest way: 503 errors are not normal. Find what is causing the
> error and fix it. Alternatively, if the 503 error is being returned
> deliberately as a status by a script, modify the script so that the script
> does a 302 redirect instead (for example, to http://google.com/music)
>
> Another way: set up an ErrorDocument on your server (not on google.com) to
> handle all 503 errors. Have this ErrorDocument be a CGI script or other
> active content. The script should examine the REDIRECT_* environment
> variables set up by Apache HTTP Server to determine which URL the user was
> requesting, and, if the user was requesting /music, the script should
> generate a 302 response to redirect the user to http://google.com/music
> If the user was not requesting /music, then the script should do whatever
> you want done in the case of a 503 error (display an error message for the
> user, etc.). For details, see https://httpd.apache.org/docs/**
> 2.2/custom-error.html<https://httpd.apache.org/docs/2.2/custom-error.html>
>
> A harder way: Write an Apache HTTP Server module to do exactly what you
> want. An alternative to writing a module in C would be to use mod_perl:
> https://perl.apache.org/docs/**2.0/user/handlers/http.html<https://perl.apache.org/docs/2.0/user/handlers/http.html>
>
> I hope this helps.
>
> --
> Mark Montague
> mark@catseye.org
>
>
Re: [users@httpd] Mod Rewrite for Server Status 503, depending upon
URL
Posted by Mark Montague <ma...@catseye.org>.
On September 16, 2011 2:58 , Ujjwal Kumar <uj...@bankbazaar.com>
wrote:
>
> * /music is not a physical directory
>
What is /music? Is this URL proxied? Is the content for this URL
generated by a script? Something else?
> * In one sentence, the problem is to redirect specific urls (a) to a
> page only if that specific url (a) has a 503 error.
>
The easiest way: 503 errors are not normal. Find what is causing the
error and fix it. Alternatively, if the 503 error is being returned
deliberately as a status by a script, modify the script so that the
script does a 302 redirect instead (for example, to http://google.com/music)
Another way: set up an ErrorDocument on your server (not on google.com)
to handle all 503 errors. Have this ErrorDocument be a CGI script or
other active content. The script should examine the REDIRECT_*
environment variables set up by Apache HTTP Server to determine which
URL the user was requesting, and, if the user was requesting /music, the
script should generate a 302 response to redirect the user to
http://google.com/music If the user was not requesting /music, then
the script should do whatever you want done in the case of a 503 error
(display an error message for the user, etc.). For details, see
https://httpd.apache.org/docs/2.2/custom-error.html
A harder way: Write an Apache HTTP Server module to do exactly what you
want. An alternative to writing a module in C would be to use
mod_perl: https://perl.apache.org/docs/2.0/user/handlers/http.html
I hope this helps.
--
Mark Montague
mark@catseye.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org