CodeIgniter 預設可以設定多個專案目錄配置,但是它的配置方式跟我想要的不太一樣,我想配置的結構如下面的 目錄結構,CodeIgniter 核心就一個目錄位置,每個專案都有它自己的目錄、index.php、.htacess、以及自己的application目錄。所以改以下面這方式來重新配置 CodeIgniter 專案。目錄結構:
[www/] [system/] [CodeIgniter 核心目錄] [project_1/] [CodeIgniter預設的application目錄] .htacess index.php [project_2/] [CodeIgniter預設的application目錄] .htacess index.php
修改 index.php:
找到 $system_folder = 『system』;
修改 $system_folder = 『../system』;找到 $application_folder = 『application』;
修改 $application_folder = 『../專案目錄名稱』;
去除網址上的 index.php:
修改 .htacess
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ /根目錄/專案目錄/index.php/$1 [L]修改 config/config.php
找到 $config['base_url'] = http://example.com/;
修改 $config['base_url'] = 『http://專案網址』;找到 $config['index_page'] = 『index.php』;
修改 $config['index_page'] = 『』;
結論:
這樣的配置方式以後如果要更新CodeIgniter核心的話,就只需要更改一次 [system/]這個目錄就可以,每個專案有它自己的index.php、.htacess、目錄,這樣看起來就清楚多了。
相關文章


