【发布时间】:2019-12-05 13:45:54
【问题描述】:
如果用户通过移动设备打开网站,我想将 mydomain.com 定向到 m.mydomain.com。我使用 mobiledetect.net,并使用作曲家安装了它。当我尝试通过手机打开网站时,我收到错误通知“ERR_TOO_MANY_REDIRECTS”。
这是我的控制器:
class Welcome extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('url');
}
public function index()
{
$detect = new Mobile_Detect;
if($detect->isMobile()) {
header("location: http://m.mydomain.com");
exit;
}
}
}
我该如何解决这个错误?
我只使用 CI 文档中的默认 htaccess
HTACCESS
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
【问题讨论】:
-
请出示您的 .htaccess 或 windows 等效文件
-
我只使用 CI 文档中的默认 htaccess
标签: php codeigniter