对 example.com/username 与路由的意见

发布于 2024-07-09 22:17:03 字数 257 浏览 11 评论 0原文

我正在建立一个网站,用户有自己的“个人资料”。 我正在使用简洁 URL 的路由,我想知道以下内容的优点/缺点是什么:

example.com/:username

或者我应该包含一个静态路由来过滤它是个人资料页面请求吗?

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

哪个最好?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

硬不硬你别怂 2024-07-16 22:17:03

如果用户可以指定他们的用户名并以显着的方式自定义他们的个人资料页面,那么您将面临遭受欺诈/网络钓鱼攻击的风险。

例如,我可以使用用户名“passwordreset”进行注册,然后在我的个人资料页面上放置一个表单(或表单的链接),然后尝试说服人们需要通过访问 example.com 来重置密码/重设密码。

然后我就可以获取密码了。

如果 URL 是 example.com/users/passwordreset,则警报用户更有可能变得可疑。

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.

奢华的一滴泪 2024-07-16 22:17:03

我认为您不会想要,

example.com/:username

因为这会对可用的用户名施加限制,以免与网址下的其他路径发生冲突。

我会建议

profiles.example.com/:username

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文