我们知道,一些网站的页面和用户页面的URL的结构是一致的。
比如 http://dribbble.com/designers
和 http://dribbble.com/username
还有 https://github.com/explore
和 https://github.com/username
在这种情况下,应该有个保留字列表来防止用户注册到我们在使用或者将来可能用到的字符串。
比如我能想到的api, about, job, explore, message, admin, auth, page, news
等,你觉得还有哪些?
感谢 @gaosboy 和 @felix021。
避免保留字问题的最简单的方法就是像 @gaosboy说的加个命名空间。看了一些网站的URL设计也是这样:
http://www.v2ex.com/member/airyland
http://www.douban.com/people/airyland/
另外需要考虑的:
- 不允许纯数字
- 小于4个字符的保留
- 可能应用于二级域名的保留 (@felix021)
- 保留与保留字部分字形相似的字符,如o=0,l=>1 (@felix021)
关于可能的保留字,找到了Quora 上的一个问题:How do sites prevent vanity URLs from…
整理后的一个列表:
about
account
activate
add
admin
administrator
api
app
apps
archive
archives
auth
better
blog
cache
cancel
careers
cart
changelog
checkout
codereview
compare
config
configuration
connect
contact
create
delete
direct_messages
documentation
download
downloads
edit
email
employment
enterprise
facebook
faq
favorites
feed
feedback
feeds
fleet
fleets
follow
followers
following
friend
friends
gist
group
groups
help
home
hosting
hostmaster
idea
ideas
index
info
invitations
invite
is
it
job
jobs
json
language
languages
lists
login
logout
logs
mail
map
maps
mine
mis
news
oauth
oauth_clients
offers
openid
order
orders
organizations
plans
popular
post
postmaster
privacy
projects
put
recruitment
register
remove
replies
root
rss
sales
save
search
security
sessions
settings
shop
signup
sitemap
ssl
ssladmin
ssladministrator
sslwebmaster
status
stories
styleguide
subscribe
subscriptions
support
sysadmin
sysadministrator
terms
tour
translations
trends
twitter
twittr
unfollow
unsubscribe
update
url
user
weather
webmaster
widget
widgets
wiki
ww
www
wwww
xfn
xml
xmpp
yaml
yml
以前我做的时候是这样的
- 两个字的全部保留
- 不允许全数字
- admin null root 这种关键字保留(看你能想到多少了)
最重要的一点,在你没有100%把我的时候,开放给用户的数据,不直接挂在域名后边,一定要隔一层,像SF这样 http://segmentfault.com/u/gaosboy
4个以内字符的都应该保留。4个以上的:
1. 管理员之类的应当避免(webmaster,administrator,root)
2. 如search/mail/pop/smtp等比较可能用在二级域名的也应该避免,
3. 最好能排除看起来掉类似上述的,比如adm1n, r00t,这个可以写个代码来判断是否像
我知道有一个:string
这个注册了也是没用的,比如FTP的帐号,