views:

413

answers:

2

I'm setting up a site where users have their own "profile". I'm using routes for neat URLs and I wondered what are the pros/cons to the following:

example.com/:username

Or should I include a static route to filter that it's a profile page request?

example.com/u/:username
example.com/something-static/:username

Which is best?

+1  A: 

I don't think you'd want

example.com/:username

as that would put restrictions on the usernames available so as not to clash with other paths under the url.

I would propose

profiles.example.com/:username
DanSingerman
I have all of the static routes I need. I am also reserving some and I can always do example.com/something-static/my-new-page if I get really stuck in the future? (where something-static is already reserved)
ed209
+3  A: 

If it is possible for the user to specify their username and customize their profile page in a significant way, then you run the risk of enabling fraud/phishing attacks.

For example, I could register with a username of "passwordreset", and then put a form (or a link to a form) on my profile page, and then try to persuade people that they need to reset their passwords by visiting example.com/passwordreset.

Then I could harvest the passwords.

If the URL was example.com/users/passwordreset, there is more chance that an alert user would become suspicious.

Oddthinking
can't I just prevent anyone registering any username with "password" in it? (and other strings like forgot, username, reminder etc...)
ed209
Good luck coming up with a complete list.Don't forget "FAQ" and "Help"... "Passw0rd" and Unicode-camouflage... "Contraseña" and other languages... Common typos in your reserved words...
Oddthinking
@ed209 - If you really want to do it the first way you mention then you really can - but you have 2 answers here which suggest why perhaps you shouldn't. @Oddthinging - agreed; I have never known a system where such design decisions have been made up front and been seen to be correct in hindsight.
DanSingerman