What is the best practice for creating a unique URL for each user profile

In my application, I want to create a unique URL for the user profile as http://app.com/username .

I have a username: 'Vijay Kumbhar', I can create http://app.com/vijay_kumbhar , but if there is another user register with the same name, what would be the best way to create a URL for this user . one way to add vijay_kumbhar_1 but i don't think this is the right way to create a unique url

Could you suggest me the best way to do this.

+4
source share
5 answers

Keeping the user's attention, firstly, provide the user with a unique identifier with which you can easily identify the user. After that, you can allow the User to select any new username (screen name), but again there must be a check that the username must be unique again. Depends on your requirement. Tell us how you stayed.

+3
source

You can use the same approach as stackoverflow using

stackoverflow.com/users/unique-number/user-name

+2
source

Usually usernames should be unique. If you use the login in the URL, they will be unique. It is generally accepted to prevent two users with the same login from registering.

EDIT: If you want usernames not to be shown (for example, for some security reasons), you can use URLs from user accounts in hashes, and not for logins, for example. app.com/mylogin> app.com/123123123

+1
source

You most often register your registered users in some kind of database. In SQL, it is natural that each row has a unique identifier. You can use this identifier as part of the URL, rather than your own number for each name combination.

0
source

You definitely need to make sure that you do not show the actual "username" in the URL if you have a public URL.

If you use an ID, just remember to avoid the mistake Wordpress made by sequentially creating user IDs starting with the default admin user as "1".

This made it easier for hackers to request something like

example.com/profile?author=1

It will return

example.com/admimuser

And show him the actual admin username ... and then the cracker will start knocking, trying to overdo the admin password.

And never show the login name to anyone or any URL other than the user or administrators!

0
source

All Articles