2013-06-29 56 views
0

我想從代碼點火器URL刪除的index.php刪除的index.php,我創造了的.htaccess文件並將其存儲在應用程序文件夾平行的index.php,並刪除想從Codigniter URL

$config['index_page'] = ''; 

from config.php。

代碼在.htaccess文件,這是不工作:項目

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

網址是:

localhost/WCPM/index.php 

注意請不要紀念這個問題是重複的,因爲我已經爲相同的嘗試了很多解決方案,但沒有一個適合我,所以最後我問這個問題在這裏解決方案

回答

1

In Config.php Change as

$config['index_page'] = ''; 
$config['base_url'] = 'http://localhost/WCPM/'; 

創造的.htaccess文件

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

和[WCPM]根文件夾即近應用程序文件夾保存此。

有關詳細信息,請參考CI手冊@http://ellislab.com/codeigniter/user-guide/general/urls.html

+0

它的工作原理..謝謝 – Ekky

0

在apache中啓用mod_rewrite模塊。

如果不工作或mod_rewrite並已經啓用,試試這個

<IfModule mod_rewrite.c> 
RewriteEngine On 

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

</IfModule> 
0

首先,改變你config文件以下setting

$config['index_page'] = ''; 

,然後,更換.htaccess文件位於項目的根文件夾沒有與下面的代碼的應用程序文件夾..

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

如果沒有則檢查.. HTTP的開始: //stackoverflow.com/questions/5155333/remove-index-php-from-url-codeigniter-2 –

+0

http://ellislab.com/codeigniter/user-guide/general/urls.html+ –

0
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|imgs) 
RewriteRule ^(.*)$ index.php/$1 [L] 
RewriteRule ^media/imatges/([0-9]+)/([A-Za-z0-9-]+).jpg?$ imgs/$1 [T=image/jpeg,L] 
<Files "index.php"> 
AcceptPathInfo On 
</Files> 

這是整個推薦的代碼把你的.htaccess文件