Welcome Guest, Not a member yet? Register   Sign In
Best way to generate part of a URL that is just used for visuals/seo
#6

[eluser]Aken[/eluser]
Redirects for this is silly, IMO.

First of all, if you URL structure is actually following the controller/function/parameter/parameter logic, your function will load regardless of how many parameters are in the URL.

If I have a controller "blog" with a function "view", I can enter this URL and that function will load properly:
Code:
http://mysite.com/blog/view/19/monkeys-are-weird/checkoutmy/123/hahaitjustkeepsgoing/cheeseiepoofs

The downside to that is obviously a URL with that type of directory structure doesn't exist. So in the off chance that you generate an incorrect URL, it will still be accessible, which can lead to odd search engine additions and things of that nature.

My suggestion, if you think it's necessary to avoid that possibility, is to create a set of routes to control what is available and what is not. These four rules, going from most specific to most generic, will prevent all URLs except 'controller/function/id/a-title-goes-here' from working:
Code:
$route['controller/function/:num/:any/:any'] = 'sandbox/notfound';
$route['controller/function/(:num)/:any'] = 'sandbox/blog/$1';
$route['controller/function/(:num)'] = 'sandbox/blog/$1';
$route['controller/function/:any'] = 'sandbox/notfound';

These routes most likely could be improved upon (you can use regular expressions to make things even more specific), but they work as a quick solution.


Messages In This Thread
Best way to generate part of a URL that is just used for visuals/seo - by El Forum - 07-19-2011, 11:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB