codeigniter子域使用与域相同的控制器

时间:2014-01-13 11:06:15

标签: php codeigniter subdomain

我想将我的网站的移动版本创建到子域m.mysite.com,我发现最好的方法是创建具有相应文件夹的子域,在本例中为m,并生成index.php文件加载控制器及其所需的任何数据,但主域中的views文件夹除外。

在这种情况下,有人能告诉我index.php文件应该是什么样的。

我的主要index.php看起来像这样

<?php

if ($_SERVER['SERVER_ADDR'] == '127.0.0.1'){

    error_reporting(E_ALL);

} else {

    error_reporting(E_ALL);

}



$system_path = "system";

$application_folder=strncasecmp($_SERVER['REQUEST_URI'],'/admin',6)==0 ? "app/admin":"app/frontend";

    //  $application_folder = "app/frontend";



if (realpath($system_path) !== FALSE){ $system_path = realpath($system_path).'/'; }

$system_path = rtrim($system_path, '/').'/';

if ( ! is_dir($system_path)){ exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME)); }

define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));

define('EXT', '.php');

define('BASEPATH', str_replace("\\", "/", $system_path));

define('FCPATH', str_replace(SELF, '', __FILE__));

define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));     

if (is_dir($application_folder)){

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

} else {        

    if ( ! is_dir(BASEPATH.$application_folder.'/')){ exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF); }

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

}
date_default_timezone_set('Europe/Bratislava');

require_once BASEPATH.'core/CodeIgniter'.EXT;

0 个答案:

没有答案