我需要路由例如「www.url.com/controller/function」我把路由代碼放在'config.php'中,但是不起作用。我需要加載到相同的控制器的意見,沒有把'index.php'在URL中。有可能的?我如何路由到控制器和codeigniter功能?
-1
A
回答
0
這裏是幫助URL從URL刪除的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文件將被包含在您的網址:
www.url.com/index.php/controller/function
通過使用帶有一些簡單規則的.htaccess文件,您可以輕鬆地刪除此文件。下面是這樣一個文件的一個例子,使用「負」的方法中,一切都被重定向除指定的項目:
RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]
將含有上述代碼.htaccess文件到你的應用程序的根文件夾。
你的實際問題是什麼?你想從url中刪除index.php嗎? – chhameed 2012-08-09 04:23:41
你實際上是RTFM嗎? ;) – 2012-08-09 08:10:04
@Hameed我會採納你的建議。我真的想展示給不同的意見,而不需要把index.php /控制器 – MrSanders 2012-08-09 15:25:26