我有一个codeigniter的问题,我找不到一个解决方案。
我如何通过解析成url的目的地url重定向而不解释/作为控制器模型等之间的分隔符
例如:http://www.example.com/http://www.google.com/?q=test
将http://www.google.com/?q=test
作为字符串放入
Header("Location: http://www.google.com/?q=test");
有什么想法吗?
您可以使用url帮助器的重定向函数。如果你给它一个完整的地址(http://),),它将重定向到外部url。https://ellislab.com/codeigniter/user-guide/helpers/url_helper.html
redirect("controller_name/function_name");
此代码使用 header function in php
等于base_url() + redirect value
如果成功了,
我使用url库,如有建议的Juul,代码是这样的(在控制器):
class url extends CI_Controller {
function index() {
# the codeigniter not accept the characters after ? and i make a custom code
# to know where is the ? sign and then i replace http:/ whith two //
$url = str_replace(":/","://",str_replace('%5E','?',$this->uri->uri_string));
#the url var will return http://www.google.com/?q=test
}
}