大网数据广告活动
网站运营与故障问答

Should my users' profile page URL be /user/bob or just /bob?

· 52CE 我爱测

Currently, the URL to a user's page is this: website.com/user/bob But I'm considering changing this to be: website.com/bob Without the /user/ part. It comes across as much cleaner and easier to access, as user pages are one of th…

问题原文

原帖链接 · user896541 · CC BY-SA 3.0

Currently, the URL to a user's page is this:

website.com/user/bob

But I'm considering changing this to be:

website.com/bob

Without the /user/ part. It comes across as much cleaner and easier to access, as user pages are one of the most frequently-visited pages on my site.

I have, however, a few questions:

  1. Is this something I should do? Is it SEO friendly?
  2. Would this be done within my code (my routes file) or would it be done through .htaccess or some other method?

Thanks.

社区高分解答

原帖链接 · Tim Holt · CC BY-SA 3.0

Do the /user/bob style, as there's a very good reason why you should not use /bob.

Specifically, that means you can't have any other paths in your website, as they might collide with a user name. For example, someone could name themselves "images" and now your /images folder doesn't work. Or someone who's name is "John Smith" but wants to be user "js" now is colliding with your /js folder where you put JavaScript.

Yes certainly with routing configurations you could allow this, so that /images/foo.jpg works and gives you the image "foo.jpg" in the image directory, but then /images would get you the user named images. That would basically be really confusing from the technical design perspective.

I know this isn't going to happen often, but in general it's just bad path design to have a scheme that you know can fail in some cases.

If you don't like the unfriendly naming of /user, try something else like /home or anything else you can think of that might be a bit less utilitarian.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-09-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。