【问题标题】:How do you pass a URL into a CodeIgniter controller? [duplicate]如何将 URL 传递给 CodeIgniter 控制器? [复制]
【发布时间】:2011-11-03 06:25:07
【问题描述】:

可能重复:
url encoded forward slashes breaking my codeigniter app

这是我的控制器:

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

如果我将一个普通字符串传递给 bar 函数,我会看到“hello world”打印出来。

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

如果我将一个 URL 编码的字符串传递给 bar 函数,我会得到一个错误。

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

.

找不到

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

【问题讨论】:

    标签: php url codeigniter


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-06-22
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多