2016-10-04 47 views
1

我用下面的.htaccess:Codeigniter在Get請求中沒有index.php的情況下無法工作?

AddDefaultCharset utf-8 
RewriteEngine On 

RewriteBase/
DirectoryIndex index.php 
Options All -Indexes 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

而且設置在笨:

$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 

因此,所有頁面由URL路徑domain/index.php/page

打開,但它並不適用於domain/page工作

+0

似乎不起作用htaccess的,我怎麼能查嗎?因爲mod_rewrite在 – Babaev

+0

你使用什麼版本的codeigniter? – user4419336

回答

0
RewriteRule ^(.*)$ /index.php?/$1 [L] 

嘗試改變上面的行至下面的:

RewriteRule (.*) index.php/$1 [L] 

具體地,在替代的?被去除。因此,不是將請求的URL作爲查詢字符串的一部分(這會阻止使用任何其他查詢字符串),而是將其作爲附加的PATH INFO來傳遞。

圍繞RewriteRule圖案的錨點也不是必需的。並且替換上的斜線前綴也可以被刪除 - 這就是RewriteBase指令的用途。

Options All -Indexes 

而且,這不是嚴格有效。你不應該混合+/-參數與沒有。這也許應該只是:

Options -Indexes 
0

試試這個的.htaccess

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

在配置文件

$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 
+0

如果您有任何疑問,請告訴我! –

相關問題