在项目中有用到redirect(index/index);
然后url中的地址就变成了http://www.**.com/m=index&a=index
有没有好的方法让跳转变成http://www.**.com,不需要后面的m=index&a=indexthinkphpredirectphp

解决方案 »

  1.   

    他是这样定义的// URL重定向
    function redirect($url, $time=0, $msg='') {
        //多行URL地址支持
        $url = str_replace(array("\n", "\r"), '', $url);
        if (empty($msg))
            $msg = "系统将在{$time}秒之后自动跳转到{$url}!";
        if (!headers_sent()) {
            // redirect
            if (0 === $time) {
                header('Location: ' . $url);
            } else {
                header("refresh:{$time};url={$url}");
                echo($msg);
            }
            exit();
        } else {
            $str = "<meta http-equiv='Refresh' content='{$time};URL={$url}'>";
            if ($time != 0)
                $str .= $msg;
            exit($str);
        }
    }不会出现你说的情况,所以也不存在改写的问题
      

  2.   

    你自己定义的index/index当然有参数了,
    $this->redirect("/");还有,最多只能到http://*.com/index/index,后面的默认参数是去不了的
      

  3.   

    如果你只是跳转到网站首页,那干嘛不用header('location: http://www.**.com,');