Welcome Guest, Not a member yet? Register   Sign In
User link - route all request that generates 404
#1

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

You have modified the autoload file?
Can you post the psr4 in that file?
Reply
#3

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 )
Reply
#4

(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!
Reply
#5

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 )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB