删除索引的问题.php在 Codeigniter 上没有加载我的 css 和 js


Problem with removing index.php on Codeigniter didn`t load my css and js

目前我试图在codeigniter url上删除索引.php。我在localhost/jqm/withci上安装了我的代码点火器。然后我写 .htaccess 来删除索引.php它运行良好。.ht访问文件 :

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

但我m having some problem, my css file and js won不加载..我的主演是

class Home extends CI_Controller {
    function __construct() {
        parent::__construct();
        $this->load->helpers('url');
    }
    function index() {
        $this->load->view('head_view');
        $this->load->view('main_view');
        $this->load->view('foot_view');
    }
}

我对head_view的看法是:

<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="width=320; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
    <title>jQuery Mobile with Codeigniter</title>
      <link rel="stylesheet" href="<?php echo base_url();?>jquery.mobile/jquery.mobile-1.0a4.1.css" type="text/css" charset="utf-8" />
      <script type="text/javascript" src="<?php echo base_url();?>jquery.mobile/jquery-1.5.2.js"></script>
      <script src="<?php echo base_url();?>jquery.mobile/jquery.mobile-1.0a4.1.js"></script>
    <!-- CDN Respositories: For production, replace lines above with these uncommented minified versions -->
    <!-- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />-->
    <!-- <script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>-->
    <!-- <script src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>-->
    </head>
  <body>

我尝试使用base_url((,但它没有t load my css and js. Thank you.. PS : I使用jQuery Mobile的css和js文件。我们可以从 CDN 存储库加载它,但我想让它可以从我自己的目录加载,以防将来我想加载自定义 css 或 js

.htaccess文件中,将包含 JavaScript 和 CSS 的文件夹添加到重写条件中,如下所示:

RewriteCond $1 !^(index'.php|images|jquery'.mobile|robots'.txt)

目前,这些文件未加载,而是指向您的index.php文件。

尝试将其添加到重写规则中,以防止在所有文件和目录上进行重写:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

您可以在配置文件中设置一个新的配置变量,但在其上设置css/js文件的路径