2011-01-24 33 views
1

我正在使用drupal转到page.tpl.php如果匿名用户试图访问/节点/编辑,以便其重定向到/ home page,这是我如何检查Drupal转到无限重定向

global $user; 
if($user->uid !=1){ 
    if($_REQUEST[q] =='node/edit'){ 
     echo "IN IF"; 
     drupal_goto('/', '', $fragment, 301); 
    }else if($_REQUEST[q] =='node/edit/'){ 
     drupal_goto('/', '', $fragment, 301); 
    } 
} 

,但我会得到这个错误

Firefox has detected that the server is redirecting the request for this address in a way that will never complete. 
+0

我得到了类似的问题,这是解决? – leetom 2015-10-06 09:49:13

回答

1

有几件事错。主要的是,如果你不想让匿名用户能够编辑节点,那么使用权限系统来做到这一点更好,而不是在主题层中进行。这部影片应该帮你:

http://gotdrupal.com/videos/understanding-drupal-permissions

要调试这是怎么回事,我建议Firefox的活HTTP头扩展。如果你使用它,它可以告诉你重定向的位置。从它的外观来看,你已经做出了无限的重定向循环。

+0

没有得到它的无限循环?一旦他从节点/编辑到/即回家如果条件将失败的第二次,如果我删除go_to我会得到回声中IF只有一次在我的网页上 – GoodSp33d 2011-01-24 10:46:28