【问题标题】:after removing index.php from url in codeigniter在codeigniter中从url中删除index.php后
【发布时间】:2013-10-21 19:07:10
【问题描述】:

我的登录控制器:$this->load->view('login-view');

我的重定向到“登录视图”的链接在模板中是:anchor('login','Login');

在从 codeigniter 中的 url 中删除 index.php 之前效果很好。但是从 url 中删除 index.php 后它不起作用。

我的 .htaccess 文件是:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

我认为很难解释,这就是我所拥有的。 :(

【问题讨论】:

  • 如果你像index.php/login这样称呼它,它仍然有效?
  • 你设置好config.php和routes.php了吗?
  • index.php/login 工作...但 index.php 显示在 url...
  • sry 更不用说...我在 wamp 工作,离线
  • 我已经设置了我的 config.php 像 $config['uri_protocol']= 'REQUEST_URI';和 $route['default_controller'] = "home";

标签: codeigniter


【解决方案1】:

在 .htaccess 中试试这个

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

config.php

$config['uri_protocol'] = 'AUTO';

【讨论】:

  • 不工作... :( anchor('index.php/login','Login') 工作但 url 包含 (site)/index.php/login
  • 糟糕!成功!我之前将我的 htaccess 文件放在应用程序文件夹中,现在它在我的根目录中...谢谢大家的建议
【解决方案2】:

只需从配置文件中删除 index.php。

$config['index_page'] = "index.php"; 

应该是

$config['index_page'] = ""; 

【讨论】:

    猜你喜欢
    • 2016-05-14
    • 2014-10-28
    • 2012-06-15
    • 2012-09-21
    • 2011-10-12
    • 2017-07-16
    • 2014-02-28
    相关资源
    最近更新 更多