如何在Drupal中进行绝对重定向?

时间:2015-03-04 13:33:55

标签: php drupal drupal-7

从我在Drupal 7中的自定义模块中,我想进行重定向。

所以,在一个函数中,我有:

$my_calculated_path = $base_url . '/dashboard/test/deliveries;
drupal_goto($my_calculated_path);

如果我打印变量$my_calculated_path,我有完整的网址:

www.mydomain.com/dashboard/test/deliveries

这是正确的。

问题是drupal_goto($my_calculated_path)触发了钩子菜单:

/dashboard/test

而不是菜单:

/dashboard/test/deliveries

有什么问题?

2 个答案:

答案 0 :(得分:1)

通常drupal_goto()不允许绝对路径,因为这可能代表漏洞。

以这种方式尝试:

drupal_goto('dashboard/test/deliveries/', drupal_get_destination());

drupal_get_destination()功能会为您创建正确的网址。

希望这有帮助。

答案 1 :(得分:1)

使用'外部'外部重定向选项:

drupal_goto($url, array('external' => TRUE));

请参阅:drupal_goto()url()