【问题标题】:How to remove the trailing slash from the base url codeigniter如何从基本 url codeigniter 中删除尾部斜杠
【发布时间】:2016-10-05 04:09:08
【问题描述】:

我的主页网址是http://localhost:8080/myproj/ 我需要删除尾部斜杠 我该怎么做?

因为,当我删除 index.php(使用 htaccess)时,url 变为 http://localhost:8080/myproj//projects/list url需要这样http://localhost:8080/myproj/projects/list

请帮忙

【问题讨论】:

  • 你是如何产生这个http://localhost:8080/myproj//projects/list的。显示代码。
  • 在 htaccess 中使用 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]
  • 不,我是说你使用了什么功能。 site_url() 还是 base_url()?提供此代码
  • 使用的 site_url()
  • 也许你这样使用echo site_url().'/projects/list'

标签: php codeigniter


【解决方案1】:

您的代码应如下所示

echo site_url('projects/list')

试试这个

【讨论】:

    【解决方案2】:

    尝试使用这个.htaccess

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L]
    

    本指南应该会有所帮助.. http://www.htaccess-guide.com/

    【讨论】:

      猜你喜欢
      • 2011-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-19
      • 2017-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多