I have set the Default 403 (access denied) page: to www.mysite.com/user/register

It works before. but I don't know when it suddenly doesn't work now, its showing a 'This web page has a redirect loop.' browser's page there now.

What should I do to resolve this ? thanks

Comments

freelylw’s picture

Forget to tell. I have a content type which can be post only by authenticated user. Now,when anonymous user click to post the node. I get this 'redirect loop' message.

Also everything allowed by authenticated user, if click by anonymous user, will get this message as well. example: I have the invite module installed. allowed by authenticated user only. but if any anonymous user click the link www.mysite.com/invite. he will get the message . and the page never redirect to the 'Default 403 (access denied) page'

WHAT should I do now please if you know a bit of this .

Thanks

cwebster’s picture

I was having a bit of a hard time understanding the exact results that you were experiencing, but this might help. For me, it was important to realize that the "user/register" page reacts differently based on whether the user is anonymous or authenticated.

What's Probably Happening

Anonymous Users

  1. User tries to access the protected node.
  2. Drupal identifies a 403 error, tries to serve up the 403 page, which you have defined as "user/register".
  3. Drupal should serve up the user registration form just fine.

Authenticated Users

  1. User tries to access the protected node.
  2. Drupal identifies a 403 error, tries to serve up the 403 page, which you have defined as "user/register".
  3. Drupal sees that the user is already logged in, and attempts to serve up the defined 403 page, since the user has already registered. Loop back to #2, which brings us to #3, and on and on.

In my case, I created a php node with the following code.

Possible Solution

  1. Create a new page (node/add/page), and set the input format to PHP code. (Note: If you don't have this option, you'll need to enable the PHP filter module first.)
  2. Paste the following code into the body of the page, including the <?php ?> tags:
    // If the user is NOT logged in, display the login block.
    if(!$GLOBALS['user']->uid){
      drupal_set_title('Please Log In');
      print '<h3>This page is only available to certain registered users.</h3>';
      print drupal_get_form('user_login_block');
    }
    
    // If the user IS logged in... 
    else{
      drupal_set_title('Access Denied');
      print 'You are not authorized to access this page.';
    }
    
  3. Save the page. While viewing the page, hover over the Edit tab, and make note of the node id in the URL. (For something like "http://www.site.com/node/1/edit", the node id is 1.)
  4. Go to Administer > Site configuration > Error reporting (admin/settings/error-reporting), and set the Default 403 (access denied) page to the system URL of the node you just created, such as node/1.
  5. Give it a spin!

Hope that helps. It did when I was experiencing a similar problem.

msypes’s picture

Thanks cwebster!

I was hitting the same problem, and your description matched perfectly.

Michael