Forum Moderators: phranque

Message Too Old, No Replies

block old browser rewrite question..

         

scorpion

12:10 am on Nov 18, 2003 (gmt 0)

10+ Year Member



I put this in my htaccess file, unfortunately netscape 4.7 seems to blast right through it (i.e. ignores the directive completely).

rewriteCond %{HTTP_user_agent} ^Mozilla/4\.[0-9]\ \(compatible\;\ MSIE
rewriteCond %{HTTP_user_agent} ^Mozilla/4\.[0-9]{1,2}\ \[en\]
rewriteRule ^(.*)$ /user/browser.html/$1 [R=301,L]

My idea is just to redirect to a different page if the user uses Netscape 4.xx (or older) or IE 4.xx (or older). Could the problem be the user agent is not passed when the domain is entered in the address bar?

closed

7:25 am on Nov 18, 2003 (gmt 0)

10+ Year Member



I doubt it.

I think the problem is that the pattern you're matching isn't quite right. I don't think that you should be escaping spaces.

To test your code, you should try using something like Wannabrowser to see if the UA is being blocked successfully.

jdMorgan

3:34 pm on Nov 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Missing [OR] flag?

RewriteCond %{HTTP_user_agent} ^Mozilla/4\.[0-9]\ \(compatible\;\ MSIE [b][OR][/b]
RewriteCond %{HTTP_user_agent} ^Mozilla/4\.[0-9]{1,2}\ \[en\]
RewriteRule ^(.*)$ /user/browser.html/$1 [R=301,L]

One user agent can't match both RewriteCond patterns, so the missing [OR] disables the rewrite completely.

Jim