斜杠在GET请求(用于PHP后端) [英] Slashes in GET request (to be used with PHP back end)

查看:187
本文介绍了斜杠在GET请求(用于PHP后端)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须发送GET请求到我的Apache服务器。只要参数的值只有一个单词,事情就会顺利进行。每当有空格时,我将它们更改为%20 并且它实现了诀窍

然而,只要我在我的参数值中有斜线,事情不起作用。
例如,我想发送到我的服务器的URL是:

https://randomness.com?path=/var/images/sub%20images/&name=image%2001 .jpg



我怎样才能得到解决方法?

解决方案

div>

许多字符在网址中被网页主机特别解释, / 字符就是其中之一。

您可以将 / 字符翻译为%2F ,就像翻译 %20



PHP's urlencode功能也可以自动处理这些翻译。



这些编码的参考可以在这里找到
,你应该手动处理它。

I have to send a GET request to my Apache server. Whenever the parameters have values that are just one words, things work smoothly. Whenever, there are spaces, I am changing them to %20 and it does the trick

However, whenever I have slashes in my parameter values, things do not work. For example, the URL I want to send to my server is:

https://randomness.com?path=/var/images/sub%20images/&name=image%2001.jpg

How can I get a workaround regarding this?

解决方案

Many characters are specifically interpreted by the web host in URLs and the / character is one of them.

You can translate your / characters to %2F, like you translate to %20.

PHP's urlencode function can also handle these translations for you automatically.

A handy reference for these encodings can be found here, should you wish to handle it manually.

这篇关于斜杠在GET请求(用于PHP后端)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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