mod_rewrite/rewriterule - forcing a HTTP 500 code on all access attempt?

mod_rewrite/rewriterule - forcing a HTTP 500 code on all access attempt?

am 05.12.2009 02:25:07 von Frank Z

is there a way via RewriteRule to force all access to a certain URL to retu=
rn with a HTTP 500 e.g.=A0 i have a number 3 applications that are or=
will be=A0obsoleted and is=A0expected to=A0return a=A0500 to all=A0callers=
=A0who try to access it. so when someone tries to access a deprecated =
URL such as http://myserver/myApp1=A0 I would like to send back a 500 and p=
referably some textual information (nice to have). Will it be possible=
to do this via mod_rewrite? Thanks.

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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

Re: mod_rewrite/rewriterule - forcing a HTTP 500 code onall access attempt?

am 05.12.2009 02:42:08 von Nick Kew

On 5 Dec 2009, at 01:25, Frank Z wrote:

> is there a way via RewriteRule to force all access to a certain URL to return with a HTTP 500
>
> e.g. i have a number 3 applications that are or will be obsoleted and is expected to return a 500 to all callers who try to access it.
>
> so when someone tries to access a deprecated URL such as http://myserver/myApp1 I would like to send back a 500 and preferably some textual information (nice to have).
>
> Will it be possible to do this via mod_rewrite?

(a) Don't send 500. 410 (Gone) would seem more appropriate.
(b) Yes, you can do this with mod_rewrite: just put your text in an
ErrorDocument. Or for a possibly-simpler solution, look up
mod_asis and put the entire response in a single file.

--
Nick Kew

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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

Re: mod_rewrite/rewriterule - forcing a HTTP 500 code on all access attempt?

am 05.12.2009 03:25:39 von Rich Bowen

On Dec 4, 2009, at 20:25 , Frank Z wrote:

> is there a way via RewriteRule to force all access to a certain URL
> to return with a HTTP 500
>
> e.g. i have a number 3 applications that are or will be obsoleted
> and is expected to return a 500 to all callers who try to access it.
>
> so when someone tries to access a deprecated URL such as http://myserver/myApp1
> I would like to send back a 500 and preferably some textual
> information (nice to have).
>
> Will it be possible to do this via mod_rewrite?

You can use the R flag to return any valid HTTP status
RewriteRule ^/myApp1 - [R=500]

but, as Nick says, returning a 500 for it seems to be a lot less
useful than a 404 or a 410 and an ErrorDocument.

--
Rich Bowen
rbowen@rcbowen.com




------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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

Re: mod_rewrite/rewriterule - forcing a HTTP 500 codeon all access attempt?

am 05.12.2009 13:02:14 von aw

Frank Z wrote:
> is there a way via RewriteRule to force all access to a certain URL to return with a HTTP 500
>
> e.g. i have a number 3 applications that are or will be obsoleted and is expected to return a 500 to all callers who try to access it.
>
> so when someone tries to access a deprecated URL such as http://myserver/myApp1 I would like to send back a 500 and preferably some textual information (nice to have).
>
> Will it be possible to do this via mod_rewrite?
>
It is certainly possible with mod_rewrite, but why don't you just create
a little cgi script which returns whatever you want ?
Or just set an Alias ?
Alias /my/former/page "/var/www/docs/special/my-error-page.html"

Otherwise, a 500 is a "server error", which is probably not appropriate
here. You should look for a more appropriate error code, maybe in the
300 series ? See RFC 2616. According to the HTTP specs, not all error
codes admit a response body. Also a tip : if you return an error page,
make sure it is larger than 1024 bytes or so, otherwise Internet
Explorer will substitute it with a "friendly error page" which doesn't
say anything helpful.



------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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

Re: mod_rewrite/rewriterule - forcing a HTTP 500 code on all access attempt?

am 09.12.2009 07:59:18 von Frank Z

Thanks for all your help. I ended up using the RewriteRule recommended=
below by Rich Bowen along with an ErrorDocument (as per Nick Kew) to provi=
de more details about the error. 300/400 series would have been more u=
seful but client requirements don't always make sense.=A0 However, they are=
happy that a very simple config exercise in Apache was able to solve=A0the=
problem.   =0A----- Original Message ----=0AFrom: Rich Bowe=
n =0ATo: users@httpd.apache.org=0ASent: Fri, December 4=
, 2009 6:25:39 PM=0ASubject: Re: [users@httpd] mod_rewrite/rewriterule - fo=
rcing a HTTP 500 code on all access attempt? =0AOn Dec 4, 2009, at 20:=
25 , Frank Z wrote: > is there a way via RewriteRule to force all acce=
ss to a certain URL to return with a HTTP 500=0A> =0A> e.g.=A0 i have a num=
ber 3 applications that are or will be obsoleted and is expected to return =
a 500 to all callers who try to access it.=0A> =0A> so when someone tries t=
o access a deprecated URL such as http://myserver/myApp1=A0 I would like to=
send back a 500 and preferably some textual information (nice to have).=0A=
> =0A> Will it be possible to do this via mod_rewrite? You can use the=
R flag to return any valid HTTP status=0ARewriteRule ^/myApp1 - [R=3D500]=
but, as Nick says, returning a 500 for it seems to be a lot less usef=
ul than a 404 or a 410 and an ErrorDocument. --=0ARich Bowen=0Arbowen@=
rcbowen.com =0A---------------------------------- ---------------=
--------------------=0AThe official User-To-User support forum of the Apach=
e HTTP Server Project.=0ASee f=
or more info.=0ATo unsubscribe, e-mail: users-unsubscribe@httpd.apache.org=
  "=A0 from the digest: users-digest-unsubscribe@httpd.apache.org=0AFo=
r additional commands, e-mail: users-help@httpd.apache.org =0A

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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