Welcome Guest, Not a member yet? Register   Sign In
Remove index from URL
#1

[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?
#2

[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';
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB