2017-01-06 21 views
0

我知道這個問題之前被問過很多次,而且我已經經歷了大部分,但是找不到解決方案。我已經嘗試了大多數here,here和CodeIgniter官方文檔中給出的答案。並且每次都重新啓動apache。它不適合我。 mod_rewrite已在我的apache服務器中啓用。如何使用.htaccess在CodeIgniter中刪除index.php

奇怪的是,我已經爲WAMP工作示例(在我的筆記本電腦):

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

<IfModule !mod_rewrite.c> 
ErrorDocument 404 /project/index.php 
</IfModule> 

它完美的WAMP,但它不能在LAMP工作。任何形式的幫助表示讚賞。

+0

你遵循這一步呢? $ config ['index_page'] =';;' –

+0

@prakashtank是的,我試過了。 –

+0

檢查此http://stackoverflow.com/a/31785445/4595675 –

回答

0

我把它與下面的.htaccess代碼的幫助下工作:

RewriteEngine on 
RewriteCond $1 !^(index\.php|public|\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 

我更新部分與/etc/apache2/apache2.conf文件<Directory /var/www/>

<Directory /var/www/> 
     Options Indexes FollowSymLinks 
     AllowOverride all 
     Require all granted 
</Directory> 

它解決了所有的問題,現在它工作正常。

0

請使用如下代碼:

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 

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

我用這個和它的工作。

0

試試下面的代碼在.htaccess文件

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /ROOT DIRECTORY NAME/ 

    # Directs all EE web requests through the site index file 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

<Directory "/path/to/document/root/"> 
    AllowOverride All 
    Allow from All 
</Directory> 
0

就這樣......

.htaccess inyour根目錄與下面的代碼..

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

設置配置在application/config.php如下。

$config['base_url'] = 'http://domain_name'; 

$config['index_page'] = ''; 

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

這裏是我的方法:

RewriteEngine on 
RewriteBase/

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

而且還config.php文件替換

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

$config['index_page'] = "" 

,並在同一個文件替換

$config['uri_protocol'] ="AUTO" 

通過

$config['uri_protocol'] = "REQUEST_URI" 
相關問題