Redirect to a custom page in hook_init() I need to redirect users to a custom page using hook_init().

I have tried drupal_goto(), but it is not working fine. By using drupal_goto(), it is looping and it is not giving the correct result. 

So, for that, I have checked a condition using drupal_get_destination(). But, it is not working correctly. 

Here is the code: 

$destination = drupal_get_destination();

foreach($compatible_arr as $key =&gt; $val) {
if(isset($browser_arr[$key])) {
    if(version_compare($browser_arr[$key], $val, '&lt;')) {
        //print strpos($destination['destination'], 'browser-limitations');
        if(strpos($destination['destination'], 'browser-limitations') == '') {
            drupal_goto($base_url.'/browser-limitations/', array('query' =&gt; array('version' =&gt; $val)));
        }
    }
}


I am using this condition in order to check the browser version using the Mobile Detect module. But, I am not getting the correct result. Is it safe to use drupal_goto() in hook_init()? Or else, is there any function to use it?
If you define the redirect in hook_init, then it would work for non cached pages. But in case of Cached pages it would not work.

So it is recommended to use hook_boot instead of hook_init.

hook_boot would help you in redirecting for cached pages as well.