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:
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.
Expired session temporary files will be automatically deleted only when the session temporary files are located in the temporary directory of the operating system
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