【问题标题】:Codeigniter posted double link in address bar when clicking href单击href时,Codeigniter在地址栏中发布了双链接
【发布时间】:2016-10-14 11:35:11
【问题描述】:

帮我处理这段代码。

 <a href="<?php echo site_url('calculator/');?>"><< Kembali menghitung</a>

当我点击它发布的双倍链接时: http://localhost/belajarci/index.php/calculator/localhost/belajarci/index.php/calculator

我试图删除 href 值,但页面没有引用主页,它只是更改了我代码中的另一个值。

【问题讨论】:

  • 你检查过解决方案了吗?
  • 您需要将 /application/config/config.php 中的 $config['base_url'] 设置为您的 CodeIgniter 根目录 - 使用尾部斜杠。例如| example.com

标签: php codeigniter


【解决方案1】:

它是在双 url 上重定向是对的,因为您需要在文件/控制器构造函数中包含 $this-&gt;load-&gt;helper('url') 或在 autoload.php

中使用 url helper >

还要在配置中做两件事:

  1. 检查项目中的 .htaccess 文件,因为可能是您在那里设置了任何 url 重定向。
  2. 在配置文件中检查您在此处设置的基本 url。

【讨论】:

    【解决方案2】:

    您正在获取此网址:

    http://localhost/belajarci/index.php/calculator/localhost/belajarci/index.php/calculator
    

    因为您需要在 文件/控制器构造函数 中包含 $this-&gt;load-&gt;helper('url') 或在 autoload.php 中使用 url 助手

    加载 url helper 后,您的 URL 将按您的需要工作。

    您也可以按照 CI 用户手册:https://codeigniter.com/userguide3/helpers/url_helper.html

    【讨论】:

    • @MochamadRamdannyLukman:如果帮助接受答案,这将有助于其他人点击左侧的勾号。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-28
    • 1970-01-01
    • 2013-11-01
    • 1970-01-01
    • 2020-11-10
    • 1970-01-01
    • 2017-04-20
    相关资源
    最近更新 更多