避免url使用加号"+"

问题

线上对一个url的请求参数做了加密,突然发现参数的请求值跟解析出来结果不一样,请求参数里面有个“+”号,服务端获取时候变成“ ”,一个空格。

排查

查看nginx日志,发现在nginx获取时候已经是“ ”,于是排除服务端代码问题。经过谷歌,原来url的“+”号,在url解析时候会变成“ ”。

原因

Generally speaking, the plus sign is used as shorthand for a space in query parameters, but while it can be used in such a way in URLs, it isn’t a good idea. The plus sign is sometimes transformed into a space or to “%20” which can cause problems for the spiders crawling your site, hence causing issues with indexation. URLs with spaces are often confusing to theses spiders, especially with forums and blogs where the URL is automatically recofnised and converted into a link.

以上来自 https://www.orchidbox.com/google-recommends-avoidance-of-the-plus-sign-in-your-urls

大意很简单,就是url 的加号可转化成空格或者 “%20”.(“%20就是url空格的编码”),会给使用者带来烦恼。

解决

  1. 避免在url使用+号
  2. 如果类似加密,可能产生加号以及各种特殊符号,建议接口使用post
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值