[eluser]Iverson[/eluser]
[quote author="sheldonnbbaker" date="1233365909"]So I'm porting over an application I made a few months ago from my own framework to CI - so I'm probably gonna have quite a few questions along the way regarding best practices and how to do certain things, so here's the first one I guess:
- where is a good place to have a redirect script for misspelled URLs? e.g, if a user goes to mysite.com/book_for_sale/ instead of mysite.com/book_for_sale/id_number_554542423, I want to redirect them to mysite.com/all_books_for_sale.
Should I make a hook here - 'cause doing a redirect in the controller is kind of 'late', is it not?
Thanks
[/quote]
All you need to do is at the beginning of whatever controller function handles "mysite.com/book_for_sale/", check first to see if your book exists in your db by looking for segment 2, which is the id number. If it doesn't, just use the redirect function in your controller. Redirect() is in the URL helper.
mod_rewrite should be your last option. There are so many options in PHP and Codeigniter. I'm actually very surprised that the first suggestion to a n00b in our CI forum is to start mucking with Apache :coolmad: