CodeIgniter 多個專案目錄配置

CodeIgniter 預設可以設定多個專案目錄配置,但是它的配置方式跟我想要的不太一樣,我想配置的結構如下面的 目錄結構,CodeIgniter 核心就一個目錄位置,每個專案都有它自己的目錄、index.php、.htacess、以及自己的application目錄,所以改以下面這方式來重新配置 CodeIgniter 專案。

目錄結構

1
2
3
4
5
6
7
8
9
10
11
[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、目錄,這樣看起來就清楚多了。

Related Posts with Thumbnails

相關文章

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>