E.g. My site have two subdomains : domain_a and domain_b.

I create a path: "custom/a".

I hope:

domain_a can visit the path.

domain_b visit the path, get 404.

Except according to the golbal $domain in the code, does anyone have other solution?


There's a few ways to do that, but an easy one is to use the Panels module to define the page, coupled with domain_ctools

Then you can just add a selection rule or access control rule to specify the valid domains via the user interface.

Alternatively, you could do something with hook_menu access callbacks.

| improve this answer | |
  • Thank for your fast reply. <br/> I just found a way use contex + [domaincontext](drupal.org/project/domaincontext. And I will also try your idea. Thanks! – Rylyn Jun 25 '13 at 3:30
  • Worked for me! Thank for your idea. However, I still have a little problem with it. When the domain(not allowed visit) visit the page got "Access denied". I hope to show "Not found" or custom content. Do you have any good idea ? – Rylyn Jun 25 '13 at 6:20
  • 1
    Add another "variant" to the page to match the other domain. You can also add an "http response code" variant for a 404 response. – David Thomas Jun 25 '13 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.