php关联域载入,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

php-codeigniter%E4%B8%8B%E4%BA%8C%E7%BA%A7%E5%9F%9F%E6%8C%87%E5%90%91%E5%AD%90%E7%9B%AE%E5%BD%95

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值