CodeIgniter Forums

Full Version: URL rewriting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Noob education ongoing....

Trying to learn about URL formation in CI. 1 question I can't seem to answer.

For example,
Have class Blog with function one_entry().
To access, user goes to this page address -> index.php/blog/one_entry/article-name.html.

How would I change that to index.php/blog/<b>one-entry</b>/article-name.html without renaming the function itself? That is, how do I replace _ with -?

Is this possible?

I have read the User Guide on Routing but don't think that is my answer.

I also checked this forum entry but that didn't help either but I may not have grasped all of it. Help for Custom URL.

El Forum

[eluser]Chad Fulton[/eluser]
I think Routing is your answer. Try this:

$route['blog/one-entry/:any'] = 'blog/one_entry/$1';

Why don't you think Routing is your answer? It seems like you want a pretty straightforward mapping from one URI (with one-entry in it) to another (with one_entry in it).