search queries in first part of URI |
[eluser]Sean Gates[/eluser]
Yep. I agree: 10 ways to do anything in programming. Messing a ton with routes makes it a headache down the road. Just letting him know that prefixing it would be easier. If you were doing a blog (like wordpress), then you could set your route to look for a year in the first segment (e.g.: like 2010, 4 digits). But otherwise, /search/ is a nice prefix and is also SEO friendly allowing for semantics in the URL.
[eluser]Joshua Logsdon[/eluser]
@Sean: Sounds good and you're 100% right about prefixing. Again, prefixing "cures all", so I'm not backtalking here, but I have to add this into how I came up with what I'm doing... I'm on a project where a client will be creating pages and they want the urls to look like example.com/my-page-name Trust me, I would have loved to say no, your urls will look like example.com/pages/my-page-name, but instead I kind of took it up as a challenge first. After I tried the catchall routing and found the issue with having to list all routes, I didn't want another place to manage or break if I decided to change a controller name, etc. So the small add-on (I did another to help process controller and method names with dashes) is what I came up with. In my catchall I can query if a page exists with that name and if not, spit out the 404. Also for the blog example earlier (I knew you were going to point out the 4 digit route ), address formats can vary like in Wordpress... example.com/2010/01/29/my-article, example.com/my-blog-name/my-article, etc. so in the catchall I analyze the segments to determine how things need to be looked up.
[eluser]Yednotek[/eluser]
Great replies guys! I'm sure I'll be able to build a solution to the problem now. Thanks!
[eluser]doccer[/eluser]
For those interested.. ME HMVC does a custom 404 in their MY_Router.php under the _validate_request function. So if you have a Code: $route['404'] = "site/$1"; |
Welcome Guest, Not a member yet? Register Sign In |