2017-05-09 116 views
0

我接管現有的codeigniter項目,並且在routes.php文件中沒有定義路由。但該網站的確處理自定義路線。如果在routes.php中沒有定義路由,codeigniter處理路由

這是所有沒有在路由文件:

$route['default_controller'] = "index"; 
$route['scaffolding_trigger'] = ""; 

我在版本1.7.2

編輯

<?php 

/* 



|--------------------------------------------------------------- 
| PHP ERROR REPORTING LEVEL 
|--------------------------------------------------------------- 
| 
| By default CI runs with error reporting set to ALL. For security 
| reasons you are encouraged to change this when your site goes live. 
| For more info visit: http://www.php.net/error_reporting 
| 
*/ 

    error_reporting(E_ALL); 

/* 
|--------------------------------------------------------------- 
| SYSTEM FOLDER NAME 
|--------------------------------------------------------------- 
| 
| This variable must contain the name of your "system" folder. 
| Include the path if the folder is not in the same directory 
| as this file. 
| 
| NO TRAILING SLASH! 
| 
*/ 

    $system_folder = "system"; 

/* 
|--------------------------------------------------------------- 
| APPLICATION FOLDER NAME 
|--------------------------------------------------------------- 
| 
| If you want this front controller to use a different "application" 
| folder then the default one you can set its name here. The folder 
| can also be renamed or relocated anywhere on your server. 
| For more info please see the user guide: 
| http://codeigniter.com/user_guide/general/managing_apps.html 
| 
| 
| NO TRAILING SLASH! 
| 
*/ 
    $application_folder = "application"; 
    /*$application_folder = "workshopapplication";*/ 


/* 
|=============================================================== 
| END OF USER CONFIGURABLE SETTINGS 
|=============================================================== 
*/ 


/* 
|--------------------------------------------------------------- 
| SET THE SERVER PATH 
|--------------------------------------------------------------- 
| 
| Let's attempt to determine the full-server path to the "system" 
| folder in order to reduce the possibility of path problems. 
| Note: We only attempt this if the user hasn't specified a 
| full server path. 
| 
*/ 
if (strpos($system_folder, '/') === FALSE) 
{ 
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE) 
    { 
     $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder; 
    } 
} 
else 
{ 
    // Swap directory separators to Unix style for consistency 
    $system_folder = str_replace("\\", "/", $system_folder); 
} 

/* 
|--------------------------------------------------------------- 
| DEFINE APPLICATION CONSTANTS 
|--------------------------------------------------------------- 
| 
| EXT  - The file extension. Typically ".php" 
| SELF  - The name of THIS file (typically "index.php") 
| FCPATH - The full server path to THIS file 
| BASEPATH - The full server path to the "system" folder 
| APPPATH - The full server path to the "application" folder 
| 
*/ 
define('EXT', '.php'); 
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); 
define('FCPATH', str_replace(SELF, '', __FILE__)); 
define('BASEPATH', $system_folder.'/'); 

if (is_dir($application_folder)) 
{ 
    define('APPPATH', $application_folder.'/'); 
} 
else 
{ 
    if ($application_folder == '') 
    { 
     $application_folder = 'application'; 
    } 

    define('APPPATH', BASEPATH.$application_folder.'/'); 
} 

/* 
|--------------------------------------------------------------- 
| LOAD THE FRONT CONTROLLER 
|--------------------------------------------------------------- 
| 
| And away we go... 
| 
*/ 
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT; 

/* End of file index.php */ 
/* Location: ./index.php */ 
+0

裏面是什麼你的'索引'控制器 – Jabaa

+0

檢查你是否加載了額外的插件,或對核心文件的任何修改。 –

+0

routes.php不包含路由列表..您控制器目錄中的所有控制器都被視爲路由.. – Demonyowh

回答

1

所有控制器都被認爲路線..但你也可以在你的config/routes.php中添加路由

+0

我剛剛意識到在URL中具有文件位置/名稱和方法名稱時出現了什麼問題,目錄結構正暴露給用戶。這是一個巨大的安全問題。 – Dave2345