Home  >  Q&A  >  body text

Thinkphp5 uses redirect problem

Hello teacher, I encountered a very confusing problem when using redirect in thinkphp5, I hope you can help answer it.

<?php
namespace app\index\controller;
class At extends Common
{
    public function hi($name)
    {
        if ($name == 'thinkphp')
        {
            return $this->redirect('http://www.baidu.com',302);
        }else{
            return $this->error('登录失败','ds');
        }
    }
    public function cg()
    {
        return '登录成功跳转';
    }
    public function ds()
    {
        return '登录失败跳转';
    }
}

This code follows the method the teacher said. If successful, it will jump to the Baidu web page. There is no problem in executing this code. However, when I replace the redirected url with another one, ,A problem occurred.

Replace as follows:

<?php
namespace app\index\controller;
class At extends Common
{
    public function hi($name)
    {
        if ($name == 'thinkphp')
        {
            return $this->redirect('mqqapi://card/show_pslcard?src_type=internal&version=1&uin=1921779545&card_type=person&source=sharecard',302);
        }else{
            return $this->error('登录失败','ds');
        }
    }
    public function cg()
    {
        return '登录成功跳转';
    }
    public function ds()
    {
        return '登录失败跳转';
    }
}

As shown in the code, I replaced the redirected address with an address of the mqqapi protocol (this is a protocol of QQ). When I replaced it with this When entering the address, the following error is reported:

QQ图片20171004023810.png

Logically speaking, this show_pslcard is just part of the URL of the mqqapi protocol. I don’t know why such an error occurs. Is it conflicting with something in the thinkphp framework, or is it for some other reason.

I hope the teacher can help me answer it.

芒果芒果2595 days ago2650

reply all(2)I'll reply

  • 直奔十维

    直奔十维2017-10-05 16:39:32

    Expired session temporary files will be automatically deleted only when the session temporary files are located in the temporary directory of the operating system

    reply
    0
  • qzuser

    qzuser2017-10-04 22:27:09

    thinkphp The parameter usage of the redirect method is consistent with the usage of the Url::build method. You will understand after checking the reference manual. Use it directly? It will be resolved first as accessing local methods. Unable to achieve expected results

    reply
    0
  • Cancelreply