Re: Mod Rewrite for Server Status 503, depending upon URL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



/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 <mark@xxxxxxxxxxx> wrote:
On September 16, 2011 2:58 , Ujjwal Kumar <ujjwal.kumar@xxxxxxxxxxxxxx> 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@xxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux