2011-06-10 5 views
2

현재 codeigniter url에서 index.php를 제거하려고했습니다. 내 codeigniter를 localhost/jqm/withci에 설치했다. 그런 다음 .htaccess를 작성하여 index.php를 제거하면 제대로 작동합니다. htaccess로 파일 :Codeigniter에서 index.php를 제거하지 못했습니다. 내 CSS와 js를로드하지 않았습니다.

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 wont 부하 .. 내 conroller은

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()를 사용하려고하지만, 그것은 jQuery 모바일에 대한 CSS와 JS 파일을 사용하여 t load my css and js. Thank you.. PS : I m 않았다. CDN 리포지토리에서로드 할 수 있지만 나중에 사용자 정의 CSS 또는 js를로드하려는 경우 내 자신의 디렉토리에서로드 가능하게하려고합니다.

답변

4

.htaccess 파일에 JavaScript 및 CSS가 들어있는 폴더를 재 작성 조건, 같은 :

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

는 현재 해당 파일이로드되지 않는 대신 그들은 당신의 index.php 파일을 가리키는 것입니다.

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

대단히 감사합니다. 그것은 mod_rewrite 잘 모르겠다 내 잘못이야. – justmyfreak

3

한번에 모든 파일과 디렉토리로 발생에서 재 작성을 방지하기 위해 그것에 파일

0

당신은 설정 파일에 새로운 설정 변수를 설정하고 있지만, CSS/JS 경로 : 당신의 재 작성 규칙이 추가

관련 문제