CodeIgniter Forums
Remove index from URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Remove index from URL (/showthread.php?tid=11476)



Remove index from URL - El Forum - 09-10-2008

[eluser]harmstra[/eluser]
I have a fresh installed CI.

I created one controller, index.php
Contents:
Code:
function index()
    {
        echo "index";
    }
    
    
function test()
    {
        echo "test";
    }

Routes:
Code:
$route['default_controller'] = "index";

Config:
Code:
$config['index_page'] = "";

htacces:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|src|ext)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [QSA]

When i go to www.domain.com, 'index' is echood on screen
When i go to www.domain.com/index, 'index' is echood on screen
When i go to www.domain.com/index/test, 'test' is echood on screen
When i go to www.domain.com/test , PAGE NOT FOUND


How do i get www.domain.com/test working?


Remove index from URL - El Forum - 09-10-2008

[eluser]xwero[/eluser]
www.domain.com/test is not working because CI thinks you are looking for a controller named test not a method test of the class index.

You can make it work with a route
Code:
$route['(test)'] = 'index/$1';



Remove index from URL - El Forum - 09-10-2008

[eluser]harmstra[/eluser]
Ok, thanks. That works great