Routing issue - again!

I am fairly new to code igniter and cant seem to get my head around the uri routing thing. I have read numerous threads here but still can't seem to apply it to my own problem.

I think it should be straight forward to do, but just dont get it.
I have the following routing:
$route['page/index/CONTACT-US/:any'] = "page/contact";
so if the url is blah/page/index/CONTACT-US everything gets sent to this page/contact

but I also want to be be able to pass in parameters.
The contact function its like this

function contact($msg=null){}

I just want to pass the paramters into the function so for example:

then the function would get "thanks" in the msg variable.

Any help kindly appreciated!!

Wrap the :any in brackets, and then change the right hand side of the expression to use $1 for the first variable (and $2 for the next and so on)

So you'll want something like
$route['page/index/CONTACT-US/(:any)'] = 'page/contact/$1';

Also, not sure if you want the contact us string to be upper case, but I recommend lower case
Also, you could probably get rid of index from the rule as well

Oh, and welcome to CI Smile

Thanks very much for that! :-) i have spent ages trying to figure it out. It was just the user guide does not put the brackets on! but when I did put them on it worked! Thanks very much!!!

[quote author="jdav3579" date="1245558407"]It was just the user guide does not put the brackets on![/quote]

And I quote...
$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";

A URL with "product" as the first segment, and anything in the second will be remapped to the "catalog" class and the "product_lookup_by_id" method passing in the match as a variable to the function.

That sure looks like some brackets to me Wink
You must have stopped reading after the first example, which doesn't have any

ha! I think now I see where I was going wrong! I was looking at this one:
$route['product/:any'] = "catalog/product_lookup";
Cheers! :-)

It's ok, I'm sure you'll remember to read the whole page next time you get stuck Wink

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.