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

jus*_*eak 2 php mod-rewrite codeigniter

目前我试图删除 codeigniter url 上的 index.php。我在 localhost/jqm/withci 上安装了我的 codeigniter。然后我编写 .htaccess 来删除 index.php 并且它运行良好。.htaccess 文件:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /jqm/withci/index.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)

但我没有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');
    }
}
Run Code Online (Sandbox Code Playgroud)

我对 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>
Run Code Online (Sandbox Code Playgroud)

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

tpl*_*ner 5

在您的.htaccess文件中,将包含 JavaScript 和 CSS 的文件夹添加到重写条件中,例如:

RewriteCond $1 !^(index\.php|images|jquery\.mobile|robots\.txt)
Run Code Online (Sandbox Code Playgroud)

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