是"|"推荐的语义URL分隔符? [英] Is '|' a recommended separator for semantic URLs?

查看:105
本文介绍了是"|"推荐的语义URL分隔符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在研究了Google和SO之后,对此似乎有矛盾的看法.

After researching Google and SO, there seems to be conflicting opinions on this.

我们遇到了Google Chrome将|分隔符替换为%7C的问题,而Firefox和Safari没有.

We have run-in to a problem with Google Chrome substituting | separator as %7C, whereas Firefox and Safari do not.

这是一个例子:

http://www.example.com/page1|sub-page2|sub-page-3

为语义URL选择分隔符时是否要遵循严格的规则,并且是否有使用(c0>时使用的替代方法)的强力论据?

Are there any strict rules to follow when choosing a separator character for semantic URLs and are there any strong arguments against (or workarounds when) using |?

推荐答案

|在URL中不是有效字符.现代浏览器在发送时会将其默默地编码为%7C,并且可能会或可能不会在地址栏中显示此更改.同样,服务器将为您静默解码字符.

| is not a valid character in a URL. Modern browsers will silently encode it to %7C when sending, and may or may not display this change in the address bar. Similarly, servers will silently decode the character for you.

在上个千年中这可能是个问题,浏览器会因为未指定http://而崩溃,但今天您可以使用所需的任何内容,而浏览器会照顾好它.但是,自动解析器(例如 http://example.com/test|fish Markdown可能不同意)是有效的网址.在这种情况下,看起来确实如此,但是请在我的论坛上尝试一下,它会向您抱怨.

This would have been a problem in last millennium, where browsers would crash just because you didn't specify http://, but today you can just use whatever you want and the browser will take care of it. However, automatic parsers such as http://example.com/test|fish Markdown may not agree to it being a valid URL. In this case, it looks like it does, but try that on my forums and it will complain at you.

这篇关于是"|"推荐的语义URL分隔符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆