2015-09-24 61 views
0

我有幾條未使用的路線和尋找解決方案來重定向這條路線。Opencart重定向定義的路線

例如,我有['common/cart','affiliate/edit' ]

路由的陣列,並且其中,我可以添加檢查,以檢查是否路線是此數組中重定向到404?我認爲可以在/controller/common/seo_url.php完成?

回答

1

有很多地方,你可以添加你重定向的條件下,最重要的是避免改變核心庫的代碼,所以我覺得最好的地方是在index.php

  • 打開文件<OC_ROOT>/index.php
  • 搜索的代碼段:
if (isset($request->get['route'])) { 
    $action = new Action($request->get['route']); 
} else { 
    $action = new Action('common/home'); 
} 
  • isset部分,你可以檢查變量$request->get['route']匹配任何陳舊的路線和重定向在此基礎上,例如:
if (isset($request->get['route'])) { 
    $ignored_routes = array('common/cart', 'affiliate/edit'); 
    if(in_array($request->get['route'], $ignored_routes)) 
     $action = new Action("error/not_found"); 
    else 
     $action = new Action($request->get['route']); 
} else { 
    $action = new Action('common/home'); 
} 


PS: 你的假設是錯誤的,你不能在文件/controller/common/seo_url.php中做,你想要的是<OC_ROOT>/system/engine/action.php;)