Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts

    user agent condition (no match)

    Hi
    Trying to create a condition where if the user agent string does not match give a forbidden
    anyone know why my code does not work?

    Updated works now
    Code:
    RewriteCond %{HTTP_USER_AGENT} !^user-agent*
    RewriteRule .* - [F,L]
    Thanks
    Sonny
    Last edited by sonny; 02-07-2013 at 02:37 AM.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,608
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Why are you trying to block visitors based on their useragent? Anyone would be easily aboe to get around the block simply by editing their useragent to match what you want it to be. Some browsers even allow the useragent to be set to different values for different sites. All of the popular browsers (except possibly for Chrome) allow the browser owner to easily set the useragent to any value they like.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    Why are you trying to block visitors based on their useragent? Anyone would be easily aboe to get around the block simply by editing their useragent to match what you want it to be. Some browsers even allow the useragent to be set to different values for different sites. All of the popular browsers (except possibly for Chrome) allow the browser owner to easily set the useragent to any value they like.
    I'm not looking to block users based on user agent, I am allowing in certain cases as part of a wider approach etc I figured it out very easy just need to escape properly and format like !^...*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •