如何将URL传递给CodeIgniter控制器? [英] How do you pass a URL into a CodeIgniter controller?

查看:162
本文介绍了如何将URL传递给CodeIgniter控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

url encoded forward slashes break my codeigniter app

这是我的控制器:

class Foo extends Controller
{
   public function bar($url) {
       echo 'hello world';
   }
}

如果我把一个正常的字符串传入bar函数,我看到你好世界打印出来。

If I pass in a normal string into the bar function, I see "hello world" printed out.


http://website.com/index.php/foo/bar/argument

如果我通过URL编码字符串到bar函数中,我得到一个错误。

If I pass in a URL encoded string into the bar function, I get an error.


http://website.com/index.php/foo/bar/http%3A%2F%2Fwww.yahoo。 com


找不到

Not Found

请求的网址/index.php/foo/bar/http://www.yahoo.com在此服务器上找不到

The requested URL /index.php/foo/bar/http://www.yahoo.com was not found on this server.


推荐答案

使用 base64_encode() base64_decode()来编码/解码网址,但您可能需要在允许的uri配置中添加更多字符。

use base64_encode() and base64_decode() to encode/decode the url, but you may need to add more character in your permitted uri config.

这篇关于如何将URL传递给CodeIgniter控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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