我有一个非常奇怪的问题
,好吧,问题是,
假设我有这个 url
http://www.example.com/?file=WFS010C.part3.rar&url=http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
如果我这样做 base64_encode($_GET['url'])
结果是这样的
aHR0cDovL3d3dy5maWxlc2VydmUuY29tL2ZpbGUvdkVwQnlwMy9XRlMwMTBDLnBhcnQzLnJhcg
==
应用此重写条件后
RewriteEngine On
RewriteBase /
RewriteRule ^file-(.*)-(.*)\.html$ index.php?file=$1&url=$2
网址如下
http://www.example.com/file-WFS010C.part3.rar-http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar.html
现在如果我这样做 base64_encode($_GET['url'])
结果是这样
aHR0cDovd3d3LmZpbGVzZXJ2ZS5jb20vZmlsZS92RXBCeXAzL1dGUzAxMEMucGFydDMucmFy
**请注意,如果 $_GET['url'] 的值在两种情况下完全相同不编码打印!!!
为什么相同的字符串在使用重写后给出不同的结果?**
有谁知道问题是什么
I have a really strange problem
ok the problem is thus
let say I have this url
http://www.example.com/?file=WFS010C.part3.rar&url=http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
If I do base64_encode($_GET['url'])
the results is this
aHR0cDovL3d3dy5maWxlc2VydmUuY29tL2ZpbGUvdkVwQnlwMy9XRlMwMTBDLnBhcnQzLnJhcg
==
after applying this rewrite condition
RewriteEngine On
RewriteBase /
RewriteRule ^file-(.*)-(.*)\.html$ index.php?file=$1&url=$2
The url is like this
http://www.example.com/file-WFS010C.part3.rar-http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar.html
now if I do base64_encode($_GET['url'])
the results is this
aHR0cDovd3d3LmZpbGVzZXJ2ZS5jb20vZmlsZS92RXBCeXAzL1dGUzAxMEMucGFydDMucmFy
**Note that the value of $_GET['url'] is exactly the same in both cases if printed without encoding!!!!
how come same string giving different results just after using rewrite ?**
Does anyone know whats the problem
发布评论
评论(3)
您可以使用
base64_decode
来查看它们是否相同。事实上:
第一个是
http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
第二个是
http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
你可以看到,它们并不相同。
You can use
base64_decode
to see whether they are same.In fact:
The first one is
http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
And the second one is
http:/www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
You can see, they are not same.
您正在重写 URl,以便将第二个
-
之后的部分存储在url
参数中。因此,在第二种情况下,您会收到url
=http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar.html
。就像你以前一样。您正在编码的内容用粗体标记:
第一个 url
http://www.example.com/?file=WFS010C.part3.rar&url=http://www.fileserve.com/file/vEpByp3/WFS010C。 part3.rar
对于第二个 URL,您将其重写为
http://www.example.com/index.php?file= WFS010C.part3.rar&url=http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
更新您的第二个base64_encoded URL正在解码为
http:/www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
。请注意 http 后面的单个/
。您确定第二个网址没有拼写错误吗?You are rewriting your URl so the part after the second
-
is stored inurl
parameter. So in second case you receiveurl
=http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar.html
. Just like you had before.What you are encoding is marked with bold:
With first url
http://www.example.com/?file=WFS010C.part3.rar&url=http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
With second URL you are rewriting it to
http://www.example.com/index.php?file=WFS010C.part3.rar&url=http://www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
UPDATE your second base64_encoded URL is decoding to
http:/www.fileserve.com/file/vEpByp3/WFS010C.part3.rar
. Note single/
after http. Are you sure you have no typos in second URL?首先,您需要对“url”参数进行 urlencode。我猜测该参数由于其中包含“/”等无效字符而无法正确解析。
First you need to urlencode the 'url' parameter. I'm guessing the parameter does not get correctly parsed because of invalid characters like '/' in it.