7

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!

1
  • See routing in documentation. Commented Dec 6, 2012 at 0:21

1 Answer 1

12

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:

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

3 Comments

Thank you my friend! Will mark your answer as best as soon as 10 minutes is up. :)
Above will call index function for other functions in view-topic controller too.
This is not a good long term solution. As Rohan mentioned, this will match all methods in the view-topic controller so unless this controller only uses a single method this will not scale.

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.