doq13207 2012-03-24 03:02
浏览 63
已采纳

在Codeigniter URL段中传递URL

I want to pass a url like http://example.com/test?a=1&b=2 in url segment of codeigniter.

I'm trying to pass something like this http://myurl.com/abc/http://example.com/test?a=1&b=2 and get the "http://example.com/test?a=1&b=2" url. What should be the best way to do this?

  • 写回答

4条回答 默认 最新

  • dongyuan7981 2012-03-24 04:32
    关注

    Set your URI protocol to REQUEST_URI in application/config/config.php , like this:

    $config['uri_protocol'] = 'REQUEST_URI';
    

    then use GET method:

    $this->input->get('a');
    

    EDIT:

    Since http://example.com/test?a=1&b=2 is not encoded URL, it isn't possible. So first, I would encode URL with urlencode function like this:

    urlencode('http://example.com/test?a=1&b=2');
    

    it returns something like: http%3A%2F%2Fexample.com%2Ftest%3Fa%3D1%26b%3D2

    So I would pass the URL like this:

    http://myurl.com/?url=http%3A%2F%2Fexample.com%2Ftest%3Fa%3D1%26b%3D2
    

    then get an example URL with GET method.

    $this->input->get('url');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 5037端口被adb自己占了
  • ¥15 Error in check.length("fill") : 'gpar'成分'fill'的长度不能为零
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误