I have to change www.sample.com/users/user/username
to www.sample.com/username
when sitename/username it display 404 page.
i tried route and uri->segment but i can't.
pls help
views:
581answers:
3Add this line to your config/routes.php
file.
$route['(:any)'] = "users/user/$1";
Note that if you do this, you'll have to manually add exceptions for other controllers/actions to work. So if you have a posts controller, your routes file is now:
$route['posts'] = "posts";
$route['posts/(:any)'] = "posts/$1";
$route['(:any)'] = "users/user/$1";
And you'll have to do this for every controller/action you have that's not users/user. You would also have to prevent usernames from being the same names as your other controllers/actions also.
In your system/application/config/routes.php
, add this:
$route['^(?!<otherController1>|<otherController2>).*'] = "users/user/$1";
Please note that you need to replace the <otherController1>|<otherController1>
with actual names of your other actual controllers, like:
$route['^(?!welcome|post).*'] = "users/user/$1";
And because you wouldn't want the other methods of your Users controller to collide with the usernames, we need to route all the other Users controller methods. For example:
$route['user/subscribe'] = "user/subscribe";
$route['user/username_exists'] = "user/username_exists";
$route['user/email_exists'] = "user/email_exists";
$route['user/signup'] = "user/signup";
i want to send more than one parameter as "user/sample/1/2" ...can anyone plz help me??