duanchen1937 2015-04-12 19:06 采纳率: 0%
浏览 24

Codeigniter试图用css文件连接资产

I am working on my first codeigniter project and am trying to put my styling in an assets folder, as it looks like that is best practice. I have tried to set it up the way others have but something is not working! Any help appreciated.

My file structure:

application
assets->css->style.css   

I made a helper application/helpers.utlity_helper.php which contains the following:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

 if ( ! function_exists('asset_url()'))
 {
   function asset_url()
   {
      return site_url().'assets/';
   }
 }

I set it to autoload:

$autoload['helper'] = array('url','form', 'utility');

My .htcaccess file:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]

My routes.php file has:

$route['assets/(:any)']='assets/$1';

And finally, in my header I have:

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

But the styles in my style file are not showing up! Please let me know if you see an error or if you know why this is. Thank you!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条