Welcome Guest, Not a member yet? Register   Sign In
A questions about routes file
#1

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
Reply
#2

(This post was last modified: 01-07-2015, 08:02 AM by Avenirer.)

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/ge...thod-calls), or why not put profile-page as the default controller and pass the id to the index method with the same __remap method...
Reply
#3

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.

Reply




Theme © iAndrew 2016 - Forum software by © MyBB