问题原文
原帖链接 · 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:
- Is this something I should do? Is it SEO friendly?
- Would this be done within my code (my routes file) or would it be done through
.htaccessor 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
