Im在CodeIgniter中使用PHP在Web应用程序中工作,并且im卡住了:P 它很难解释,所以我用一个例子来展示它。URL重定向不会总是工作?
我有正常的CodeIgniter控制器。在这个控制器我有这样的功能:
<?php
public function groups($subdomain ='') {
$this->load->library('MyLogin');
$user_id = $this->mylogin->logged_in();
if ($subdomain == '') {
.....
} elseif ($subdomain == 'create') {
.....
} elseif ($subdomain == 'join') {
.....
} elseif ($subdomain == 'leave') {
.....
} elseif ($subdomain == 'assign') {
.....
} else {
.....
}
}
的LOGGED_IN功能检查,如果谁在加载这个页面(子页面)的用户登录。如果不是他在这样的LOGGED_IN功能被自动重定向:
echo header("Location: /user/login");
5分钟前,这工作得很好。现在我创建了一个新的子域'assign'。
现在,如果在没有登录即时通讯,并尝试连接到以下网址我总是得到重定向
localhost/user/groups
localhost/user/groups/2
localhost/user/groups/create
localhost/user/groups/join
localhost/user/groups/leave
之一,但如果IM连接到
localhost/user/groups/assign
他尝试加载这个页面(什么因为$ user_id为空而不起作用)。 为什么......这是否发生?
Regards Teifun2
'header()'有** NO **返回值。 'echo header(...)'完全没有意义。 –
为了记录,您对'$ subdomain'的使用不是针对子域的,而是针对子目录的。 – Dan
@MarcB Ups:P谢谢你会改变这种情况,(但并不能解决我的问题) – Teifun2