【问题标题】:Codeigniter failed to load error 404Codeigniter 无法加载错误 404
【发布时间】:2017-04-03 17:59:28
【问题描述】:

无法使用 codeigniter 加载出现错误 404 的 css 文件。

这是我的链接标签

<head>

    <link rel="stylesheet" type="text/css" href= "<?php echo base_url();?>css/style.css">

<head>

服务器文件夹

-httpdocs
---application
---cgi-bin
---css --> style.css
---system
---user_guide

错误

GET http://31.8.7.79/css/style.css 

我不确定这是否是个问题,但由于某种原因,codeigniter 使用这个 http 地址 http://31.8.7.79/ 而不是 http://www.someurl.com 可能是因为 Apache 服务器吗?

尝试在没有 Apache Server 的情况下对不同的服务器做同样的事情,并且效果很好

【问题讨论】:

  • 您必须在 config.php 中设置您的基本网址,否则链接将无法正常工作

标签: php apache codeigniter


【解决方案1】:

在文件application/config/config.php中设置base_url项如下,看看是否有帮助

$config['base_url']  = 'http://www.someurl.com/';

【讨论】:

    【解决方案2】:

    Config.php

    $config['base_url']  = 'http://www.someurl.com/';
    

    .htaccess

    RewriteEngine on
    
    RewriteCond $1 !^(index\.php|css|(.*)\.css|(.*)\.js|(.*)\.jpg|(.*)\.jpeg|(.*)\.png|(.*)\.bmp|(.*)\.gif|(.*)\.doc|(.*)\.shtml|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ ./index.php/$1 [L]
    

    【讨论】:

      猜你喜欢
      • 2013-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多