1

I am having trouble removing the controller name from my url path on my localhost.

i have this url - localhost:8888/localhost/site_name/

i have been able to remove index.php from the url using my htaccess similar to http://codeigniter.com/wiki/mod_rewrite so that:

localhost:8888/localhost/site_name/index.php/controller_name

is now:

localhost:8888/localhost/site_name/controller_name/

but i can't remove the controller name from the path so that:

localhost:8888/localhost/site_name/controller_name/function_name/

becomes:

localhost:8888/localhost/site_name/function_name/

I am using only one controller, and i have added:

$route['^(function_name1|function_name2|function_name3)(/:any)?$'] = 'controller_name/$0'; 

$route['^(?!ezstore|ezsell|login).*'] = "home/$0"; /*similar variation i tried*/

and other variations to my routes file but it does not have any effect. i also tried using the _remap function but that does not help in this case.

Any help will be appreciated! Thanks

1 Answer 1

1

You can use a wildcard route,

$route['(:any)'] = "controller_name/$1";

Then when if you go to http://localhost/function_one/param1

it will call the controller controller_name the function function_once and pass param1 as the first parameter.


nb: I must point out, using only one controller for an entire site does raise warning bells for me, you may want to get your code design checked out, but that's just me.

Sign up to request clarification or add additional context in comments.

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.