i want to have a unique url for each users in my site with cakephp, www.domain.com/testuser. but with url above it will search for a controller action testuser. How can i route www.domain.com/testuser to user controller index action with testuser as paramter.
i want to have a unique url for each users in my site using cakephp
136 Views Asked by Arun At
2
There are 2 best solutions below
0

www.domain.com has some default controller and action, lets say pagescontroller and index function, now you want www.domain.com/testuser url so create one more action within the same controller named userProfile(), Now you have to direct all the request to this action from www.domain.com/ANYTHING.....
You can use unique string in place of ANYTHING or add unique ID to ANYTHING_546 which will solve your purpose.
www.domain.com/unique_ANYTHING www.domain.com/ANYTHING-36352
Read this section of the CakePHP 1.3 book. It explains how routing works. You'll have to have a route that first checks for the usernames slug and connect it with a controller and action, then all other routes.