DEV Community

VenatusDev
VenatusDev

Posted on

User directories

Hello! My friend and I have been making a website and recently we created an account system where you can view other peoples accounts and follow them. You can view an account by going to venatus.club/account?u=USERNAME but we were wondering if there is a way to use venatus.club/USERNAME to redirect instead if that makes sense. Would we have to create a directory with just a header tag whenever you create an account? Thank you for any help.

Top comments (3)

Collapse
 
luciam91 profile image
Scott Pringle

Are you using any frameworks? Most of the major frameworks in PHP provide this type of routing. As has been mentioned, I'd maybe look at not doing the first match but rather /account/<username> or something similar

Collapse
 
dmfay profile image
Dian Fay

I can't help you with the PHP, but yes, there's definitely some way to use the path part of the URL to look something up. However, you may not want it to be the very first path segment, since that means any first path segment could be a username, and you'd have a difficult time adding any other functionality. This is why Reddit (for example) has the /u/ or /user/ prefix in the path: to ensure there's no confusion as to what the thing you're looking up is. DEV goes without the prefix, I assume because all content is user-driven, but at the price of needing to filter out the potential usernames "dashboard", "notifications", "signout_confirm", etc.

There's been a lot of thought devoted over the years to how to organize URLs. Things have more or less settled on what's called RESTful semantics.

Collapse
 
msamgan profile image
Mohammed Samgan Khan

Hi,

what you are searching is SEO friendly URLs. They are made with the Help of Htaccess modification. Here you can find all the details for the same.

fell free to ask in case you don't get anything.