2017-07-16 101 views
1

我試圖從URL中刪除index.php文件刪除的index.php,但我不斷收到錯誤404 配置文件:無法從URL

$config['base_url'] = ''; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 

這是我的.htaccess文件:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 
+0

試着用'重寫規則^ $的index.php/$ 1 [L]'(*) - 改變最後一行,並嘗試。 – Tpojka

+3

只需在codeigniter 3和更新版本中提示,您就必須設置您的基本網址。 – user4419336

回答

2

你需要在你的應用程序文件夾多了一個.htaccess文件,這裏是該文件的細節:

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 
1

請複製並在你的htaccess文件粘貼下面的代碼,並把它放在根文件夾和應用程序文件夾

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$1 [L] 
0

打開config.php文件,並做以下內容替換

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

$config['index_page'] = "" 

只需更換

$config['uri_protocol'] ="AUTO" 

$config['uri_protocol'] = "REQUEST_URI" 

及其在htaccess文件就把下面的代碼

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