php-codeigniter下二级域指向子目录

1:先说明一下情况

目前项目是这样的

system                            CI框架目录

app                                应用目录

    controllers

            test1.php

            test2.php

            test.php

            test1                  二级域名目录

            test2                 二级域名目录

    ……

html                                web根目录

     index.php

www.test.cn是网站主域名,指向了html

现在打算用二个二级域名test1.test.cn和test2.test.cn,分别指向controller/test1和controller/test2 .

要求是是二级域名不能访问主域的资源,主哉不能访问二级哉名的资源.怎么实现?

2:实现方法

先在服务器中解析域名,把二级域名也指向html

修改html下的index.php,增加如下代码即可

function go_router(){
	$routing = array();
	$hostname = $_SERVER['HTTP_HOST'];
	if( $hostname == "test1.test.cn" ){
	    $routing['directory'] = 'test1';
	}else if ( $hostname=="test2.test.cn" ){
            $routing['directory'] = 'test2';
        }
	return $routing;
}

这样就实现了二级域名只能访问自己的资源

再在controllers下修改test1和test2控制器,来限制主域访问二级哉名资源

总结:codeigniter框架简单,灵活,很方便扩展需要的功能

but there was no feeling of connection to what had come before
gay porn 6 Unintentionally Hilarious Glitches Hidden in Video Games

Net sales fell by 5
christina aguilera weight lossThe Michael Emmanuel Couture Stretch Strut Fashion Show after party
xvideos
此条目发表在 网站开发 分类目录,贴了 标签。将固定链接加入收藏夹。

评论功能已关闭。