CodeIgniter Forums
A questions about routes file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: A questions about routes file (/showthread.php?tid=701)



A questions about routes file - behnampmdg3 - 01-07-2015

Hi;

How can I get www.website.com/12345678 to show www.website.com/profile-page/index/12345678  ?
I tried these but none of them work:

PHP Code:
$route['([0-9a-zA-z_-]{8})'] = "profile-page/index/$1"
PHP Code:
$route['/(:any)'] = "profile-page/index/$1"
[php]$route['(:any)'] = "profile-page/index/$1";/php]

When I type www.website.com/12345678 it goes 404 on me.

Please guide.

Thanks


RE: A questions about routes file - Avenirer - 01-07-2015

Hello. You didn't take into the consideration the reserved routes - in this case the one that is taking you to the default controller (which by default is the welcome controller). Try this and see if is working:
PHP Code:
$route['user/(:any)'] = "profile-page/index/$1"

If you still want to do as you want it to be (www.website.com/12345678) maybe you should do a redirect inside the default controller (welcome.php again...), with a __remap method (http://www.codeigniter.com/userguide3/general/controllers.html#remapping-method-calls), or why not put profile-page as the default controller and pass the id to the index method with the same __remap method...


RE: A questions about routes file - Rufnex - 01-07-2015

Your controlle can't be createt as profile-page, you have no name it profile_page (class Profile_page extends MY_Controller), then you can write your route like your example.