2011-09-02 22 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" } } ] 
    } 
} 

可以在管理/配置/工作流程/規則/反應/進口

相關問題