• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with routes.php

I have a controller named <b>controllers/contact.php</b>

I want to load this controller using either of these URLS:


So I put this in routes.php:

$route['members/contact/(:any)'] = 'contact/$1';

Yet if I load /members/contact now, it just returns a 404. What am I missing?

Try this:

$route["members/contact"]        = "contact";      // defaults to index()
$route["members/contact/(:any)"] = "contact/$1";   // looks for a $1 method

John's code might work, but you should always define the most specific routes first, so they are picked up in the proper order.
$route['members/contact/(:any)'] = 'contact/$1';
$route['members/contact'] = 'contact';

If you don't have any other functions in your contact controller, and will only need to use that controller from one of the two URLs mentioned, you can avoid the :any part.
$route['members/contact'] = 'contact';

Thanks guys, working.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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