在Codeigniter网址段中传递网址 [英] Passing URL in Codeigniter URL segment

查看:119
本文介绍了在Codeigniter网址段中传递网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想传送像 http://example.com/test?a这样的网址= 1& b = 2 在代码符号的url段中。



我想传送类似这样的讯息 http://myurl.com/abc/http://example.com/test?a=1&b=2 并获取http: //example.com/test?a=1&b=2url。

解决方案

将您的URI协议设置为 REQUEST_URI application / config / config.php 中,如下所示:

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

然后使用 GET 方法:

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

编辑



由于 http://example.com/test?a=1&b=2 不是编码的网址,因此不可能。首先,我将使用 urlencode 函数对URL进行编码,如下所示:

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

它返回类似于: http%3A%2F%2Fexample.com% 2Ftest%3Fa%3D1%26b%3D2



所以我传递的URL如下:

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



然后使用GET方法获取示例URL。

  $ this-> input-> get('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?

解决方案

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');

这篇关于在Codeigniter网址段中传递网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆