【问题标题】:After redirecting the page CSS is not getting fetched in codeigniter重定向页面 CSS 后未在 codeigniter 中获取
【发布时间】:2018-03-02 08:03:29
【问题描述】:

重定向页面后,存储在 assets 文件夹中的 css 和 js 不会在该重定向页面中获取。

这里是重定向页面的代码,这个页面的名字是interior.php

<a class="viewall pull-right" href="<?php echo base_url("details/profile/".$article->type_id); ?>">

它被重定向到的页面是profile.php,这是该页面中的css链接:

<link rel="stylesheet" href="../assets/css/style.css"/>

除了 css 和 js,我也没有得到存储在 Assets 文件夹内的 img 文件夹中的图像。 assets 文件夹位于应用程序文件夹中,与views 文件夹处于同一级别。

【问题讨论】:

  • 试试&lt;link rel="stylesheet" href="&lt;?= base_url() ?&gt;/assets/css/style.css"/&gt;
  • 确保你还在 config.php 中设置了基本 url

标签: php html css codeigniter


【解决方案1】:

不要使用相对 URL,而是使用绝对 URL。您可以使用base_url() 通过以下方式实现此目的:

&lt;link rel="stylesheet" href="&lt;?php echo base_url('assets/css/style.css'); ?&gt;"/&gt;

要使上述代码正常工作,您需要将资产文件夹移动到基本目录(应用程序的上一层)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多