2014-03-06 26 views
1

我是Codeigniter的新手,並試圖配置Codeigniter刪除CodeIgniter_2.1.4中的index.php

,但我無法刪除index.php從網址..

我通過下面這是在給定userguide數據改變了.htaccess文件..

.htacess文件包含

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

並且還改變了配置文件

$config['index_page'] = ''; 

當我嘗試使用下面的鏈接它導致

所請求的網址/笨/網頁/視圖在此服務器上找到。

http://localhost/codeigniter/pages/view 

但我試着用的index.php在url..The網頁正常顯示..

http://localhost/codeigniter/index.php/pages/view 

是這樣的.htaccess問題,或者我必須要改變一些其他的文件..

如何擺脫這個問題?

任何建議,可以接受。

更新

我使用的ubuntu 3.10

我用下面的命令來啓用模塊重寫

sudo a2enmod rewrite 

結果如下

Module rewrite already enabled 

我改變了權限在

/etc/apache2/sites-enabled/000-default 

由於

ServerAdmin [email protected] 

DocumentRoot /var/www 
<Directory /> 
    Options FollowSymLinks 
    AllowOverride All 
</Directory> 
<Directory /var/www/> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all 
</Directory> 

改變這個文件還沒有運氣後..

回答

1

最後我找到了答案,我question.As下面的.htaccess解決我的問題..

<IfModule mod_rewrite.c> 

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

    </IfModule> 

感謝所有..

0
以下線的 httpd.conf(在Windows上)

取消註釋

LoadModule rewrite_module modules/mod_rewrite.so

在Ubuntu 更改

+0

我在哪裏可以找到codeigniter中的http.conf文件..?我是新的codeigniter .. – PHPCoder

+0

它不是在codeigniter – Ravi

+0

告訴我你的操作系統? – Ravi

0

後使用sudo a2enmod rewrite

重新啓動Apache使mod_rewrite讓這改變

在config.php

$config['index_page'] = ''; 

IN根.htaccess文件

DirectoryIndex index.php 

RewriteEngine On 

RewriteCond $1 !^(index\.php|themes|utils|robots\.txt|favicon\.ico) 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !-d 

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

它不接受在我的Ubuntu 3.10和顯示同樣沒有找到消息 – PHPCoder

+0

檢查堆棧溢出流中的此網址:http://stackoverflow.com/questions/14848325/trying-to-remove-index-php-from-url-in-codeigniter – MAK

0

沒有人提到變化的設置。在你的httpd配置文件中查找和更改像這樣

<Directory "/var/www/html"> # your DocumentRoot setting 
    Options FollowSymLinks 
    AllowOverride All # default is None 
    Order allow,deny 
    Allow from all 
</Directory>