【问题标题】:base_url including base address twice.and not loading bootstrap css filebase_url 包括两次基地址。不加载引导 css 文件
【发布时间】:2019-11-26 02:39:03
【问题描述】:

codeigniter 的新手,尝试使用 base_url() 函数加载引导 css 文件的简单代码。在 stackoverflow 上尝试了一些答案,但问题没有解决。

我的视图名称是....articles_list.php 我的控制器名称... user.php

我按如下方式编辑 config.php 'localhost/ci';

我按如下方式编辑 autoload.php 我在 autoload.php 中加载 url 助手

articles_list.php(在视图文件中加载 css)

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

user.php(控制器)

$this->load->helper('url');
    $this->load->view('public/articles_list');

当我运行我的视图文件时,css 没有加载,当我检查视图源时它应该给我样式表 url 和链接地址为 "localhost/ci/assets/css/bootstrap.css" 但是当我看到视图源时它显示 &lt;link href="localhost/ci/assets/css/bootstrap.css"&gt; 并且当鼠标悬停在链接它向我显示localhost/ci/localhost/ci/assets/css/bootstrap.css 链接地址。请 帮我解决这个问题并帮助我学习codeigniter。

【问题讨论】:

    标签: php twitter-bootstrap codeigniter


    【解决方案1】:

    确保您在application/config/config.php 文件中正确设置base_url

    $config['base_url'] = 'http://localhost/ci/';
    

    当然要确保使用正确的.htaccess

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

    【讨论】:

    • 感谢 sherif salah... 使用 http:// 后,它在 view-source 中提供了正确的 URL。
    猜你喜欢
    • 2016-12-06
    • 1970-01-01
    • 1970-01-01
    • 2021-04-12
    • 2018-09-08
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多