-4

我移植了一些编辑脚本,这些脚本会反复调用 CI。他们第一次工作得很好,但第二次就不行了。我看到它是不断增长的 URI。

在尝试在我的脚本中查找错误,或者我将它们放在子文件夹等的事实之后,我发现它与此无关。

我设置了这个基本测试: CONTROLLER test_edit 除了获取 url-string 什么都不做:

  index() 
  {   
      $data['uri_string']=uri_string(); 
      $this->load->view('test_edit',$data);
   }

   index2() 
   {  
      $data['uri_string']=uri_string(); 
      $this->load->view('test_edit',$data);
   }

VIEW test_edit 只显示 url 字符串和到 CONTROLLER 的链接:

  <p>URI=<?=$uri_string ?></p>;
  <p><a href="test_edit">test_edit</a></p>;
  <p><a href="test_edit/index2">test_edit/index2</a></p>;

这导致
URI=
在第一次单击第一个链接之后
URI=test_edit/index

在第二次单击第一个链接
URI= test_edit/test_edit/index 等之后。
单击第二个链接将(显然)给出 404 错误。

我的问题:-WTF 导致这个???为什么每次调用都没有刷新 URI(缓存?),或者添加了哪些段:浏览器、路由器类?

注意:不要给我关于使用 base_url 的问题,URI 翻译的重点不是使用绝对标准 URL 或绝对路径。我知道如何解决这个问题,但我不想这样做。我想明白。

4

1 回答 1

1

像这样声明<a> tags

<a href="<?=base_url('test_edit/index2')?>">test_edit/index2</a>

代替:

<a href="test_edit/index2">test_edit/index2</a>

如果不使用,base_url()则使用:anchor()CI

anchor('string_path', 'title');
于 2013-09-17T15:21:18.543 回答