I have the following URL which will work :
www.example.com/police/alarm/5
However, in my database i have a table with some name values, one of the values is 'car'.
I want to dynamically route my url that if one of the name values is the first segment in my URL, ignore it and reroute without it. (I will set some variables based on this value in my constants file).
The code I have so far in my routes.php file is:
require_once(BASEPATH.'database/DB.php');
$db =& DB();
$query = $db->where('org_type', 2)
->get('organization');
$result = $query->result();
foreach( $result as $row )
{
$route[ $row->name.'/:any' ] = '$1';
}
This gives me the following result (doing a var_dump):
D:\wamp\www\codeigniter\codeigniter\application\configoutes.php:76:
array (size=11)
'default_controller' => string 'home' (length=4)
'404_override' => string 'error/my404' (length=11)
'translate_uri_dashes' => boolean false
'login' => string 'auth/login' (length=10)
'recoverAccount' => string 'auth/recover' (length=12)
'car/:any' => string '$1' (length=2)
'truck/:any' => string '$1' (length=2)
When I browse to an url containing 'car' or 'truck' as the first part in my URL, it does not reroute to the url without it.
edit:
$route[ $row->name.'/:any' ]
or
$route[ $row->name.'/(:any)' ]
result is still the same