Detect and Block UC Browser

For my website running on WordPress, I want to block readers accessing it from UC Browser.. I have come across some scripts that can block the usual suspects (Chrome, Firefox, Safari, etc.). Is there a way I can detect UC Browser and block access via it?

Here are the details of UC Browser’s User Agent:

Read More
  1. http://www.whatsmybrowser.org/b/434TWLW
  2. http://bit.ly/1YlL8fW

How can this be done?

Related posts

3 comments

  1. Use following .htaccess file:

    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^.*UCBrowser.*$ [NC]
    RewriteRule .* - [F,L]
    

    It will block any browser which send User-Agent header containing string UCBrowser.

    If you want to redirect all UCBrowser users to specific page, for example showing information that this browser is not supported, your .htaccess should look like this:

    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^.*UCBrowser.*$ [NC]
    RewriteRule .* browser-not-supported.html [L]
    
  2. Please Try this, this script will blocked old and latest all UCBrowser and redirect to custom page

    RewriteCond %{HTTP_USER_AGENT} ^.*UBrowser.*$ [OR]
    RewriteCond %{HTTP_USER_AGENT} ^.*UCBrowser.*$ [NC]
    RewriteRule .* browser-not-supported.html [L]
    
  3. It is somewhat “simple”, but not “too simple”.

    You may detect the browser using JavaScript Window Navigator. The window.navigator object contains information about the visitor’s browser.

    Refer here http://www.w3schools.com/js/js_window_navigator.asp and you will find a demo here https://jsfiddle.net/wvbdnb8o/ which detects some common browsers using some code like;

    var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
    

    Next, create a “mask” using html and css. I mean, A full screen, opaque <div>, that prevent readers from viewing the contents of page. You may refer this stackoverflow post How to make a <div> always full screen?.

    When you detect UC Browser, display the mask, else, hide it. Hope this will give you a kick start.

Comments are closed.