Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter - Remove "Index" From URL

NOTE: I'm not talking about removing index.php - I mean index - the method name.

My current URL looks like this:

www.mysite.com/view-topic/index/my-topic

This is what I want it to look like:

wwww.mysite.com/view-topic/my-topic

How would I go about doing this?

Thanks in advance!

like image 399
user1453094 Avatar asked Dec 06 '12 00:12

user1453094


1 Answers

You can set up the routes for this, in application/config/routes.php, add a new line:

$route['view-topic/(:any)'] = 'view-topic/index/$1';

This will route your URL http://url.com/view-topic/anythinggoeshere will mask the view-topic/index/anythinggoeshere controller.

More information on routing:

  • Routing with Codeigniter
like image 136
MacMac Avatar answered Nov 20 '22 19:11

MacMac