CodeIgniter Forums

Full Version: User link - route all request that generates 404
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
You have modified the autoload file?
Can you post the psr4 in that file?
Did you try this?

PHP Code:
$routes->add('profile/(:any)''Profile::userbyname/$1'
(06-10-2019, 01:38 AM)Matleyx Wrote: [ -> ]You have modified the autoload file?
Can you post the psr4 in that 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 Smile. 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