dongmo6937 2015-01-04 09:26
浏览 25
已采纳

codeigniter中的奇怪链接行为

This is one of those problems that make me question my sanity. I'm using php, codeigniter framework, removing index.php from URL with mod rewrite in htaccess.

I'm at this address

http://localhost/health/users/bob/progress/

I click a link that takes me to

http://localhost/health/users/bob/progress/01-04-15

Then I click on a link that takes me back to

http://localhost/health/users/bob/progress/

Now here's the strange thing. I click on the same link that earlier took me to

http://localhost/health/users/bob/progress/01-04-15

But instead, now it's taking me to

http://localhost/health/users/bob/progress/progress/01-04-15

I've gone through the steps a dozen times now. This is definitely the behavior it's giving me. It even happens when I do a full refresh. I actually have to visit a different address, then return to get the link at

http://localhost/health/users/bob/progress/

to work properly again. I'm guessing it's either related to the mod rewrite, or some other rewrite behavior in the codeigniter framework.

  • 写回答

2条回答 默认 最新

  • dongxibeng5324 2015-01-04 10:16
    关注

    I'm pretty sure you are using a relative path for the link that goes something like:

    <a href="/somerelativepath">link here</a>
    

    I would suggest that you use CI's base_url instead so that the link becomes absolute:

    <a href="<?=base_url()?>/nowabsolutepath">link here</a>
    

    the base_url is set on your configuration file. Please let us know how it goes!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)