1

How can I remove controller name from url . I have two controller

 home and admin

and the url's are

 http://domain.com/likes/home/post/sports/20-Athletes-Who-Profited-While-in-College-/12

  home/post

and

  http://domain.com/likes/admin/ad_managment/edit/2

  http://domain.com/likes/admin/meta_tags_home/edit/2

   admin/ad_managment   admin/meta_tags_home

I have already used this

   $route['(:any)/(:any)/(:num)'] = "home/post/$1";

It works for this URL

    http://domain.com/likes/home/post/sports/20-Athletes-Who-Profited-While-in-College-/12

admin is not working. Basically I want to remove home/post Leave admin controller it doesn't matter

3 Answers 3

6

try this

$route['(:any)/(:any)/(:any)'] = "home/post/$1";
Sign up to request clarification or add additional context in comments.

Comments

0

Try this example

$config['base_url'] = 'http://your-site.com/';
And in your routes.php

$route['default_controller'] = 'main';

Through this method you can remove controller name from url.

1 Comment

routes.php $route['default_controller'] = "home"; $route['404_override'] = ''; $route['(:any)/(:any)/(:num)'] = "home/post/$1";
0

check user guide of codeigniter and in this example see how the routing done.
Read more about code-igniter routing

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.