Force View to be displayed only in a specific domain I am using the Domain Access, Domain Access Views and Views modules.

I want to create a domain-specific view that will be displayed only in a specific subdomain of the website and if someone tries to access it from a different subdomain, he will be redirected to the proper domain.

So for example when a user navigates to:

http://www.example.com/myViewPath

or

http://customers.example.com/myViewPath

he should be redirected to:

http://blog.example.com/myViewPath.

Is there a way to do that?
One solution would be to use hook_preprocess_html()

function MYTHEME_preprocess_html(&amp;$variables) {
  global $_domain;
  if (arg(0) == 'myViewPath' &amp;&amp; $_domain['subdomain'] != 'blog.example.com') {
    drupal_goto('http://blog.example.com/myViewPath', array(), 301);
  }
}


Note that the global $_domain variable is provided by the Domain Access module.

Alternatively, in a custom module you could use hook_boot()

function MYMODULE_boot() {
  if (arg(0) == 'myViewPath' &amp;&amp; $_SERVER['HTTP_HOST'] != 'blog.example.com') {
    exit(header('Location: http://blog.example.com/myViewPath', TRUE, 301));
  }
}