用于Opera Mini浏览器的php中的URL重定向

I would like to redirect all URLs opened from Opera Mini browser to specific browser using php. I have this code below but it is not working. Please help me.

if(! empty($_SERVER['HTTP_USER_AGENT'])){

    $useragent = $_SERVER['HTTP_USER_AGENT'];
        if( preg_match('@(Opera Mini)@', $useragent)){

            $host = $_SERVER['REQUEST_URI'];

            if($host !== 'mywebsite.com/browser-error'){

                header('Location: ./browser-error');
            }
        }
}

According to dev.opera.com, opera mini user-agent has the following format:

User-Agent: Opera/9.80 ($PLATFORM_NAME$; $PRODUCT_NAME$/$CLIENT_VERSION$/ $SERVER_VERSION$;U; $LOCALE$) $PRESTO_VERSION$ $EQUIV_DESKTOP_VERSION$

Example:

User-Agent: Opera/9.80 (Android; Opera Mini/8.0.1807/36.1609; U; en) Presto/2.12.423 Version/12.16

To detect it use:

if (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false) {
    echo 'is opera mini';
}

You can use this PHP code to check the browser

<?
if(preg_match('/android.+opera m(ob|in)i/i',$_SERVER['HTTP_USER_AGENT']))
header('Location: http://');

Or try to use this PHP library

http://mobiledetect.net/