URL Rewriting: Name instead of ID |
[eluser]KingSkippus[/eluser]
[quote author="perfectsam" date="1279641053"]Hi there I'm using the bibliography management software www.aigaion.nl which uses the CI framework. I've already used the .htaccess to define a rule that removes the index.php from the URL. The database consists, among other things, of publications, topics and authors. At the moment, the URLs look like this: http://localhost/publications/show/744 http://localhost/topics/single/64 http://localhost/authors/show/281 Now would it be possible to show the publication/topic/author NAME instead of the ID in the URL, e.g. http://localhost/authors/show/john_doe or even http://localhost/authors/john_doe How could this be achieved? Thanks.[/quote] I would define in the controller two different functions in your controller, one to show by name and one to show by id. If this is software already in production use, I'd leave the show($id) function in your controller alone so that existing URLs and bookmarks don't break, and define a new function something like: Code: show_name($name) { You would access this function by http://localhost/authors/show_name/John Doe As another user pointed out, read up on URI routing to shorten your URLs with just the ID or name. Again, though, if access has historically been via the URL with "show" in it, I'd leave that one alone. |
Messages In This Thread |
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 04:50 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 05:03 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 05:05 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 05:05 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 07:20 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 06:41 PM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 07:25 PM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 01:16 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 05:57 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 06:00 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 06:08 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 06:11 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 07:54 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 07:58 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 12:25 PM
URL Rewriting: Name instead of ID - by El Forum - 07-26-2010, 10:47 AM
|