停止 Apache 解码 URL 组件


Stop Apache Decoding URL Components

我不知道

标题是否说了,但基本上,我正在使用.htaccess使用URL将整个URL传递给我的PHP文件。

示例:http://example.com/var1/var2/http://example.net/logo.png/image.png

在这种情况下,徽标.png将被我的代码放在图像中.png。

我尝试过Javascript对变量URL进行编码。

http://example.org/utilities/banner-generator/Testyz/Testy/http%3A%2F%2Fstatic.example.com%2Ffiles%2Favatar%2F1498768_1.png/banner.png

这就是 URL 的样子,但 Apache 仍然将编码的斜杠视为普通斜杠。

是否有可能阻止它这样做?

技巧

是使用B带有THE_REQUEST条件的标志。

RewriteEngine On
RewriteCond %{THE_REQUEST} 's/+utilities/banner-generator/([^/]+)/([^/]+)/(.+?)/banner'.png [NC]
RewriteRule ^ /include/image/banner.php?name=%1&description=%2&icon=%3 [NE,B,L,QSA]