【问题标题】:CodeIgniter issuesCodeIgniter 问题
【发布时间】:2016-06-02 15:58:41
【问题描述】:

1) 我想去掉 URL 中的引导程序 (index.php) 名称。 我在 YouTube 上搜索并下载了很多与此相关的视频,但没有一个工作。这是 .htaccess 文件:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !=f
    RewriteCond %{REQUEST_FILENAME} !=d
    RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

我尝试了所有可以在互联网上获得的东西。

2) 我无法加载我存储 JavaScript、CSS 和图像文件的 public 文件夹中的文件。 路径:codeigniter/application/

我尝试了什么:

<link rel="stylesheet" href="<?=base_URL() ?>public/css/default.css />

对于 JavaScript 文件也是如此。

3) 路由问题(混乱)。我的默认路由我们仪表板控制器。但我也想创建一个登录路线。所以我这样做了:

$route['login'] = 'login';

但是当我转到localhost/codeigniter/index.php/login 时,这仍然会路由到默认路由。

【问题讨论】:

    标签: .htaccess codeigniter routing


    【解决方案1】:

    试试这些.htaccess

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

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

    【讨论】:

    • 这可能还有其他因素吗?
    • @mzcoxfde 检查重写规则并检查基本 url 和索引是否正确定义。
    • 您是否尝试将 RewriteBase 从根目录添加到您的 projet 文件夹?
    【解决方案2】:

    .htaccess 文件中使用此代码,并从您的config.php 文件中删除index.php,例如$config['index_page'] = '';

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

    【讨论】:

      猜你喜欢
      • 2012-10-27
      • 2017-02-13
      • 2011-11-22
      • 2015-03-14
      • 2015-07-27
      • 2011-10-04
      • 2013-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多