User link - route all request that generates 404 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: User link - route all request that generates 404 (/showthread.php?tid=73830) |
User link - route all request that generates 404 - mirel.popescu - 06-10-2019 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! RE: User link - route all request that generates 404 - Matleyx - 06-10-2019 You have modified the autoload file? Can you post the psr4 in that file? RE: User link - route all request that generates 404 - InsiteFX - 06-10-2019 Did you try this? PHP Code: $routes->add('profile/(:any)', 'Profile::userbyname/$1') RE: User link - route all request that generates 404 - mirel.popescu - 06-15-2019 (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! RE: User link - route all request that generates 404 - InsiteFX - 06-16-2019 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 |