园子的博客主页地址默认一直是以 /
斜杠(trailing slash)结尾,比如 https://www.cnblogs.com/dudu/ ,现在在纠结是否需要去掉 /
,改为 https://www.cnblogs.com/dudu ,斜杠结尾的 url 强制跳转到结尾无斜杠的 url
不带/好看啊
嗯,好看还是挺重要的,最终决定去掉结尾的斜杠/,采用 https://www.cnblogs.com/dudu
1)影响这个决定的最主要的原因是当在浏览器地址栏输入 https://www.cnblogs.com/ ,浏览器会自动去掉结尾的 /,Chrome, Safari, Firefox, Edge 都是这样
2)其次是 stackoveflow 上的这个回答 https://stackoverflow.com/a/7364835/5989202
I'm always surprised by the extensive use of trailing slashes on non-directory URLs (WordPress among others). This really shouldn't be an either-or debate because putting a slash after a resource is semantically wrong. The web was designed to deliver addressable resources, and those addresses - URLs - were designed to emulate a *nix-style file-system hierarchy. In that context:
- Slashes always denote directories, never files.
Files may be named anything (with or without extensions), but cannot contain or end with slashes.- Using these guidelines, it's wrong to put a slash after a non-directory resource.
3)再其次是 github 用的也是结尾不带斜杠的 url ,比如 https://github.com/cnblogs
通义:
根据RFC 3986(Uniform Resource Identifier (URI): Generic Syntax)等标准,虽然不是强制要求,但 推荐 使用斜杠来区分 目录与文件,并确保URL规范化,减少由于服务器处理差异导致的问题。
是不是要以“/”结尾其实在原则上讲是要的,但是目前浏览器为了美观会不显示,但实际请求还是会携带,避免服务器错误处理,所以带不带都行,部分服务端程序也会去掉