2012-08-08 105 views
-1

我需要路由例如「www.url.com/controller/function」我把路由代碼放在'config.php'中,但是不起作用。我需要加載到相同的控制器的意見,沒有把'index.php'在URL中。有可能的?我如何路由到控制器和codeigniter功能?

+0

你的實際問題是什麼?你想從url中刪除index.php嗎? – chhameed 2012-08-09 04:23:41

+0

你實際上是RTFM嗎? ;) – 2012-08-09 08:10:04

+0

@Hameed我會採納你的建議。我真的想展示給不同的意見,而不需要把index.php /控制器 – MrSanders 2012-08-09 15:25:26

回答

0

這裏是幫助URL從URL刪除的index.php

User Guide remove index.php

,你必須使用的.htaccess文件從URL

刪除的index.php希望它可以幫助

更新

已經在應用程序\ CONFIG \ config.php文件一看,有一個名爲 'index_page'

它應該是這樣的

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

改變它

$config['index_page'] = ""; 

這裏變量是.htaccess文件,你可以使用這個..

RewriteEngine on 
RewriteCond $1 !^(index\.php|[Javascript/CSS/Image root Folder name(s)]|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 

這裏一些使用全環節..你可以按照以下..

remove index.php stackoverflow
remove index.php codeigniter forum
Enable mod rewrite from your server

希望這些可以幫助你

+0

實際上我需要顯示不同的意見,而不會把index.php /控制器/當我這樣做,所有的來源不加載。 – MrSanders 2012-08-09 15:26:59

+0

@MrSanders:親愛的我有更新我的答案。看到它,並希望現在你將擺脫index.php – chhameed 2012-08-10 03:36:24

0

默認情況下,index.php文件將被包含在您的網址:

www.url.com/index.php/controller/function

通過使用帶有一些簡單規則的.htaccess文件,您可以輕鬆地刪除此文件。下面是這樣一個文件的一個例子,使用「負」的方法中,一切都被重定向除指定的項目:

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

將含有上述代碼.htaccess文件到你的應用程序的根文件夾。