【问题标题】:codeigniter 404 not found on assets loading在加载资产时找不到 codeigniter 404
【发布时间】:2016-10-13 07:03:09
【问题描述】:

我被一个问题困扰了好几个小时,我无法摆脱它,我正在尝试从我的资产文件夹中加载我的引导文件,但出现 404 错误。

如您所见,我的资产文件夹在我的根文件夹中

我在头部使用 base_url 函数调用它:

<link href="<?php echo base_url('assets/css/bootstrap.css'); ?>" rel="stylesheet">

我在控制台中收到此错误:

获取http://127.0.0.1/WeBusy/assets/css/bootstrap.css

GET http://127.0.0.1/WeBusy/assets/js/bootstrap.min.js404(未找到)

编辑

我注意到与文件相关的所有内容都失败了,例如,如果我自动加载库会话,则会出现以下错误:

Message: mkdir(): Invalid path
Filename: drivers/Session_files_driver.php

Message: Session: Configured save path '' is not a directory, doesn't exist or cannot be created.
Filename: C:\Users\User\Dropbox\WeBusy\system\libraries\Session\drivers\Session_files_driver.php

【问题讨论】:

    标签: php twitter-bootstrap codeigniter http-status-code-404


    【解决方案1】:

    我认为您已将基本网址留空

    $config['base_url'] = '';
    

    改成

    WARNING: You MUST set this value!
    
    $config['base_url'] = 'http://localhost/WeBusy/';
    

    如果你使用的是CI3版本必须设置

    您可能需要使用 index.php

    <link href="<?php echo base_url('index.php/assets/css/bootstrap.css'); ?>" rel="stylesheet">
    

    【讨论】:

    • 不,我的基本 url 设置为 $config['base_url'] = 'http://127.0.0.1/WeBusy/';,我不需要使用 index.php,因为我的 .htaccess 中有这个:&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] &lt;/IfModule&gt;
    • $config['base_url'] = 'http://localhost/WeBusy/';中放入localhost而不是ip地址
    【解决方案2】:

    像这样访问它:

    <link href="<?php echo base_url(); ?>assets/css/bootstrap.css" rel="stylesheet">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-13
      • 2021-06-22
      • 1970-01-01
      • 2013-12-29
      • 2019-04-27
      • 1970-01-01
      相关资源
      最近更新 更多