You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Terence M. Bandoian" <te...@tmbsw.com> on 2010/07/01 01:55:10 UTC
[OT] Using httpd's mod_rewrite with mod_jk
Hi, Chris-
This should redirect to /bad-browser.shtml:
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 [R=307,L]
Looks just about like what you already had though.
I'm not sure the substitution is applied with F(orbidden).
-Terence Bandoian
Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> All,
>
> 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.
>
> 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
>
> Thanks,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkwreD0ACgkQ9CaO5/Lv0PAdXACfaFIM1rOEuuUi57+9tQfC0m/C
> OMAAnix1Hk+xb2YT6UvffIVWABYooT1R
> =GFja
> -----END PGP SIGNATURE-----
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [OT] Using httpd's mod_rewrite with mod_jk
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Terence,
On 6/30/2010 11:14 PM, Terence M. Bandoian wrote:
> Here's an alternative:
>
> RewriteCond %{HTTP_USER_AGENT} Firefox/
> RewriteCond %{HTTP_USER_AGENT}
> !Firefox/(3\.0\.19|3\.5\.9|3\.6\.3)($|[^\.0-9])
> RewriteRule .* /bad-browser.jsp [L]
>
> And set the status in the JSP.
Well, I want this to work even in situations where the servlet container
isn't running.
> By the way, I'm a little confused by the character class in the last
> pair of alternatives of second condition. Did you want "not a '.' or
> digit" or "not (a '.' followed by a digit)"?
That pattern checks for Firefox patch levels for each major, supported
version. I look for (3.0|3.5|3.6) to take care of those versions, and
then I want to make sure that there are no trailing numbers. For
instance, 3.6.3 is okay (and needs to be updated to 3.6.6, I know) but
3.6.6.2 is /not/ okay. So, that last clause checks for end-of-input or
anything-that-isnt-a-dot-or-digit.
[.] always means "a period" and not "any character" like a bare "." would.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkwtNmoACgkQ9CaO5/Lv0PDCaQCfeAxTMU0S/Bktp9ykdwf5CBw3
pjwAoIAtKs4FzZlrPGakvDq5ESGS7Utm
=2rqo
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
[OT] Using httpd's mod_rewrite with mod_jk
Posted by "Terence M. Bandoian" <te...@tmbsw.com>.
Hi, Chris-
Here's an alternative:
RewriteCond %{HTTP_USER_AGENT} Firefox/
RewriteCond %{HTTP_USER_AGENT} !Firefox/(3\.0\.19|3\.5\.9|3\.6\.3)($|[^\.0-9])
RewriteRule .* /bad-browser.jsp [L]
And set the status in the JSP.
By the way, I'm a little confused by the character class in the last pair of alternatives of second condition. Did you want "not a '.' or digit" or "not (a '.' followed by a digit)"?
-Terence
Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Terrence,
>
> On 6/30/2010 7:55 PM, Terence M. Bandoian wrote:
>
>> This should redirect to /bad-browser.shtml:
>>
>> 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 [R=307,L]
>>
>
> That's an interesting suggestion, but one that will result in one
> request getting a 403 response and then a second getting a 200 response.
> I'd prefer only a single request if possible.
>
>
>> Looks just about like what you already had though.
>>
>> I'm not sure the substitution is applied with F(orbidden).
>>
>
> It turns out that when using [F], my ErrorDocument was kicking-in, which
> was then being re-redirected by the RewriteRule, resulting in an endless
> loop that httpd finally terminated, which explains 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).
>>
>
> One option would be to set up a pass-through rule like this:
>
> RewriteRule /forbidden.html - [L]
>
> Thanks,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkwr7BQACgkQ9CaO5/Lv0PC89wCfYHB7N53ux0sqVRMR//0T6FQh
> rAoAn3WoY4/4KsU8fsglHFT88TLxkUja
> =lqk6
> -----END PGP SIGNATURE-----
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [OT] Using httpd's mod_rewrite with mod_jk
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Terrence,
On 6/30/2010 7:55 PM, Terence M. Bandoian wrote:
> This should redirect to /bad-browser.shtml:
>
> 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 [R=307,L]
That's an interesting suggestion, but one that will result in one
request getting a 403 response and then a second getting a 200 response.
I'd prefer only a single request if possible.
> Looks just about like what you already had though.
>
> I'm not sure the substitution is applied with F(orbidden).
It turns out that when using [F], my ErrorDocument was kicking-in, which
was then being re-redirected by the RewriteRule, resulting in an endless
loop that httpd finally terminated, which explains 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).
One option would be to set up a pass-through rule like this:
RewriteRule /forbidden.html - [L]
Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkwr7BQACgkQ9CaO5/Lv0PC89wCfYHB7N53ux0sqVRMR//0T6FQh
rAoAn3WoY4/4KsU8fsglHFT88TLxkUja
=lqk6
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org