User link - route all request that generates 404 |
Hello,
I want to create user profiles with the following link structure: site.tld/username. The problem is that if I use: $routes->add('(:any)', 'Profile::userbyname/$1') , it will also redirect valid controllers (ex: login, admin etc). How can I do this redirect correctly? Thanks!
Did you try this?
PHP Code: $routes->add('profile/(:any)', 'Profile::userbyname/$1') What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(06-10-2019, 01:38 AM)Matleyx Wrote: You have modified the autoload file? No, I didn't. I don't know what "psr4" is. The code: $routes->add('profile/(:any)', 'Profile::userbyname/$1') works , but then the link will be "site.tld/profile/username", not site.tld/username . Am I missing something? Thanks!
You can try this not sure if it will work, it's for CI 3.
HOW TO REMOVE CONTROLLER NAME FROM THE URL IN CODEIGNITER What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |