如何在URL中传递诸如%2f和%2b之类的编码字符? [英] How to pass encoded characters like %2f and %2b in a url?

查看:669
本文介绍了如何在URL中传递诸如%2f和%2b之类的编码字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用.htaccess文件通过URL传递加密的值,如下所示: 网址:

I am passing encrypted value through the URL using .htaccess file as shown below : URL :

http://www.website.com/folder1/f1/tdT9Eu%2b8kmAe1U%2ft12RS

htaccess文件:

htaccess file :

RewriteRule ^f1/(.+)$  index.php?id=$1 [NE]

问题是服务器通过以下方式响应:在此服务器上找不到所请求的URL.但是当我用/%2b b s+替换%2f时,它可以正常工作,并且可以看到页面的内容.

The issue is the server respond by The requested URL was not found on this server. but when I replace %2f by / and %2b b s+ it works perfectly and I can see the content of the page.

当我使用url而不进行任何重写时,它也可以完美工作,如下所示:

it works also perfectly when I use the url without any rewriting as shown below :

http://www.website.com/folder1/index.php?id=tdT9Eu%2b8kmAe1U%2ft12RS

请您提供帮助,我如何修改htaccess使其正常工作?因为我需要使用上面所示的url重写来获取内容

Could you please help with that and how can I modify my htaccess to make this work ? because I need to get the content using url rewriting as shown above

推荐答案

这是由于默认情况下Apache Web服务器通常不允许URI中存在%2f.查询字符串中允许使用它,这就是?id=...工作正常的原因.

It is due to presence of %2f in URI that is usually not allowed by Apache web server by default. It is allowed in query string that's why ?id=... is working fine.

您将需要在Apache中启用AllowEncodedSlashes指令为此进行配置.

You will need to turn on AllowEncodedSlashes directive in Apache config for this.

使用:

AllowEncodedSlashes On

允许在URI中使用编码的斜杠并重新启动Apache Web服务器.

to allow encoded slash in URIs and restart your Apache web server.

这篇关于如何在URL中传递诸如%2f和%2b之类的编码字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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