1

The controller Home has a method export:

public function export($id , $url){
     ...
}

In my smarty template, there is a link : <a href="/home/export/{%$id%}/{%$url%}">export</a>. If url is http://www.facebook.com, export method just get http: as the value of url. So i change it to <a href="/home/export/{%$id%}/{%$url|escape:'url'%}">export</a>, to escape slashes in url.

Then the location becomes ".../home/export/59/http%3A%2F%2Fwww.facebook.com%2F "(is what i want), but with "404 Not Found" Error(is not what i want).

Why is that? Shouldn't the location maps to export method? And how to map to it with full url?

4

1 回答 1

0

在 Codeigniter 控制器中,每个方法参数都来自用/斜杠分隔的 URL。对于这种工作,Codeigniter 会通过一个错误,如“URI 包含不允许的聊天对象”错误。我建议您为此任务使用查询字符串来避免所有这些问题:

http://example.com/export/?id=1&url=http://www.facebook.com

public function export()
{
    $link = $this->input->get('url');
    echo $link;
}

在 Codeigniter 中,您可以获得完整的 url:

$this->uri->uri_string()


public function export($id , $url){
     echo  $this->uri->uri_string();
}
于 2013-09-21T22:33:13.813 回答