2011-09-02 64 views

回答

2

你可以安装Path Redirect模块,它可以让你做到这一点,无需编码。

如果您使用的是Drupal 7,您需要Redirect模块。

+0

+1给予好评进口[重定向](http://drupal.org/project/redirect)也适用于Drupal 7.注意 - 一定要清除安装后的所有缓存(无论是通过管理的性能部分还是'drush cc all'),以避免致命的PHP错误:https://drupal.org/node/1948676 – therobyouknow

0

你必须下载克莱夫提到 的模块,并且你可以添加重定向到外部网站没有任何模块

1-菜单链接,进入管理/结构/菜单

2 - 的选择要将该网址添加到,然后单击菜单{添加链接}

3-加在“路径”字段中的外部路径,如下面的“http://yahoo.com”

好运

5

如果你想要的是将用户重定向到同一个网站,当他们跟着一个链接,将他们带到http://www.example.com/external,那么你可以使用类似的代码之后一个实现hook_menu()

function mymodule_menu() { 
    $items = array(); 

    $items['external'] = array(
    'title' => 'Redirect', 
    'page callback' => 'mymodule_redirect', 
    'access callback' => TRUE, 
    'type' => MENU_CALLBACK, 
); 

    return $items; 
} 

function mymodule_redirect() { 
    drupal_goto($url, array('external' => TRUE)); 
} 

如果以该用户被重定向的URL从URL中传递的值取决于,那么你可以使用类似下面的一个代码:如果要重定向现有的URL

function mymodule_menu() { 
    $items = array(); 

    $items['external/%'] = array(
    'title' => 'Redirect', 
    'page callback' => 'mymodule_redirect', 
    'page arguments' => array(1), 
    'access callback' => TRUE, 
    'type' => MENU_CALLBACK, 
); 

    return $items; 
} 

function mymodule_redirect($id) { 
    // Calculate $url basing on the value of $id. 
    drupal_goto($url, array('external' => TRUE)); 
} 
1

,通过UI另一种方式是使用流行的Rules米odule:

例如: “反应规则” 出口,网页重定向到外部域:

{ "rules_redirect_homepage" : { 
    "LABEL" : "Redirect homepage", 
    "PLUGIN" : "reaction rule", 
    "OWNER" : "rules", 
    "REQUIRES" : [ "rules" ], 
    "ON" : { "init" : [] }, 
    "IF" : [ 
     { "data_is" : { "data" : [ "site:current-page:url" ], "value" : [ "site:url" ] } } 
    ], 
    "DO" : [ { "redirect" : { "url" : "http:\/\/example.com" } } ] 
    } 
} 

可以在管理/配置/工作流程/规则/反应/进口