我试图在CodeIgniter中为我的项目使用Bootstrap模板但我遇到了麻烦。我正在按照教程进行操作,并将此内容放在.htaccess
文件中:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|fonts|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
但我的.htaccess
文件包含以下内容:
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and
leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /ci_introo/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
我该如何解决这个问题?
答案 0 :(得分:0)
您需要在配置文件中自动加载网址助手。
转到application/config/autoload.php
找到此$autoload['helper'] = array();
并将其更改为此。
$autoload['helper'] = array('url');
答案 1 :(得分:0)
你不需要.htaccess。 您要做的就是在autoload.php中添加网址
并将其放在head.php中
application/views/head.php
<html>
<head>
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/bootstrap.min.css" />
//place all css u need
</head>
控制器代码:
$this->load->view('header', $data);