2014-10-06 12 views
5

Có vấn đề với mod_rewrite trong môi trường Fast-cgi cho CodeIgniter. .htaccess của tôi trông như thế này:Làm thế nào để loại bỏ index.php từ codeigniter trong Fast-cgi

DirectoryIndex index.php 
    RewriteEngine on 
    RewriteCond $1 !^(index\\.php|images|css|js|robots\\.txt|favicon\\.ico) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php?$1 [L] 

Nhưng tôi đã nhận ra lỗi ‘Không có tập tin đầu vào quy định’.

tôi đã thay đổi để

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.* - [L] 

RewriteCond $1 !^(index\.php|images|robots\.txt) 
#RewriteRule ^(.*)$ /index.php?/$1 [QSA,L] 

<IfModule mod_php5.c> 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

<IfModule !mod_php5.c> 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

Nó chỉ làm việc với một điều này cũng:

#RewriteRule ^(.*)$ /index.php?/$1 [QSA,L] 

Vấn đề của tôi là tôi vẫn có index.php vào URL, nếu tôi thay đổi tập tin cấu hình application/config/config.php từ $ config ['index_page'] = 'index.php'; tới $ config ['index_page'] = ''; Tôi có một lỗi khác.

Tôi làm gì sai?

+3

Tôi tìm thấy giải pháp trên application/config/config.php , Tôi đã thay đổi $ config ['uri_protocol'] = 'AUTO'; tới $ config ['uri_protocol'] = 'REQUEST_URI'; – nandoC

Trả lời

0

thêm mã trong .htaccess

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

và thay đổi tập tin config.php

$config['index_page'] = 'index.php'; 

để

$config['index_page'] = ''; 
Các vấn đề liên quan