Welcome Guest, Not a member yet? Register   Sign In
URI Routing > Regex help.
#3

[eluser]Killswitch[/eluser]
[quote author="treeface" date="1278850680"]
Code:
$route['([a-zA-Z0-9]{7})'] = "mycontroller/get_something_by_id/$1";

That should do it. Get 7 alphanumeric characters, regardless of case, capture them (later referred to as '$1'), and redirect it to the uri of your choice. I only did a little bit of testing, but it seems to work.

Something you may want to think about first: what happens when you put together a "product" controller and forget that "product" is 7 characters long? You might want to have your short URLs with something like "s/([a-zA-Z0-9]{7})" such that it looks like "s/fH4J80x".[/quote]

Ah, I don't know what I did wrong but that works, and the whole products thing isn't a worry as the category stuff is restricted to only alpha characters and not numeric so only thing that has alphanumeric is the shorturl.


Messages In This Thread
URI Routing > Regex help. - by El Forum - 07-10-2010, 11:36 PM
URI Routing > Regex help. - by El Forum - 07-11-2010, 01:18 AM
URI Routing > Regex help. - by El Forum - 07-11-2010, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB