I need to show only home page and some inner pages (which i will create using a common content type) to the anonymous user. I need to redirect all other access to home page where i added a login box. Is there a way to do it.

  • is your requirement to redirect anonymous user to login page or in home page only when anonymous user access some section you have to redirect as you mentioned as accessing "light box" in home page Feb 11, 2015 at 15:40

4 Answers 4


Rather than redirect to the homepage, I would suggest using this:


it will allow you to explain to users why they've been redirected here, and also gives the the login page.

if you MUST redirect to the homepage, you can set the 403 page location to be: website.com/node

  • Is there a way to add some URLs which don't need authentication to view it.
    – drup
    Feb 11, 2015 at 15:15
  • This solution might work best with something like the Node View Permissions module. Set your permissions so anonymous users can only view the content types you want them to see, the rest should return a 403 access denied response which is where this module could take over.
    – thumbson
    Feb 11, 2015 at 15:39
  • I need to hide all taxonomy term page also from anonymous user.
    – drup
    Feb 11, 2015 at 15:51

In the permissions, make sure anonymous users don't have access. Then go to Configuration -> System -> Site information (admin/config/system/site-information). At the bottom, put your home page in 'Default 403 (access denied) page'.

All traffic going to an unaccessible page, will be redirected here.


This is sample for administrator.

global $user; 

if($user->uid = 1){ //check user here

  drupal_goto('some_page'); //redirect to some page.


it will redirect administrator to whatever page you want.

if you want anonymous user redirect.You can use user_is_anonymous().


   if(user_is_anonymous()){ //check user here

      drupal_goto('some_page'); //redirect to some page.


it will redirect anonymous to whatever page you want.


I strongly suggest the module "Anonymous Login"


This is a very simple, lightweight module that will redirect anonymous users to the login page whenever they reach any admin-specified page paths, and will direct them back to the originally-requested page after successful login.

You can also specify which pages you do not want to be restricted. These pages can be viewed by anyone. I believe it can do exactly what you're asking. Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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