On 30.06.2010 19:00, Christopher Schultz wrote:
Slightly off-topic, but relevant.
On our development servers, I'm trying to enforce a rule that all our
users have the most up-to-date web browser available (yeah, it's an
uphill battle, I know... just go with it).
I decided to use mod_rewrite to check for a User-Agent pattern and then
forward to a "bad browser" page, which works well for static content,
but not for requests destined to be handled by mod_jk.
Here's what I've got:
# Handle Mozilla Firefox
RewriteCond %{HTTP_USER_AGENT} Firefox/
RewriteCond %{HTTP_USER_AGENT}
!(Firefox/(3\.0\.19|3\.5\.9|3\.6\.3)($|[^\.0-9]))
RewriteRule .* /bad-browser.shtml [L]
For dynamic requests, this will happily allow the request to go through
to mod_jk.
Usually mod_rewrite is perfectly compatible with mod_jk. I must confess,
that I'm not 100% sure about the case, where you try to rewrite a
request that originally would have been handled by mod_jk to something
that should not be handled by it.
Two possibilities: if it doesn't actually work, you can set the env var
"no-jk" as a side effect in your rewrite rule. If mod_jk fins this env
var set, it will decline to handle the request. Alternatively, if you
are fine with redirecting by mod_rewrite instead of rewriting
internally, the redirecting should also win over mod_jk.
There is a chance though, that it should work out of the box and you are
using some indirect mapping to mod_jk that wins. That would be the case
if you are either using one of the outdated "JkOptions ForwardXXX"
options, or you are using an indirect mapping like setting the handler
to "jakarta-servlet", or using the environment variable trick
(JK_WORKER_NAME or JkWorkerIndicator) to define the target worker.
So you might want to tell us, how you map your dynamic requests
(JkMount, setting handler etc.) to mod_jk and what other Jk directives
(like JkOptions) you are using.
To complete the picture: in cases were the RewriteRule works, but then
the request is not forwarded via mod_jk although it should, you need to
add the PT flag. In your case I guess its the opposite situation you are
looking for.
Regards,
Rainer
I also tried this:
RewriteRule .* /bad-browser.shtml [L,H=alias]
This "works" in the sense that I get the page I want, but I also get a
404 error because the URL doesn't map to anything mod_alias can handle
successfully.
I also tried this:
RewriteRule .* /bad-browser.shtml [L,F]
This gives me a 403 response code, httpd's standard "forbidden" page,
and a 500 response code in the access log (looks like a runaway
redirect... I'll have to fix that).
Does anyone have any suggestions for getting:
1. My custom page rendered
2. A 403 (or any specific) response code sent to the browser
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org