IIS URL 重写重定向到图像以跟踪电子邮件视图

我正在尝试根据请求图像的文件夹名称构建一个电子邮件跟踪器。


例子:


https://www.example.com/image/123/spager.gif


需要变成这个


https://www.example.com/image/index.php?id=123


作为回报,它将提供 spacer.gif 图像。


这可行吗?如果是的话,我错过了什么?


所以票价我得到了这个:


网络配置:


<rule name="email image tracker">

  <match url="^/image/([0-9]+)/spacer.gif">

  <action type="Rewrite" url="/image/index.php?id={R:1}" />

</rule> 

索引.php:


<?php

  header('Content-type: image/gif');

  $png_image = imagecreate(150, 150);

  imagecolorallocate($png_image, 15, 142, 210);

?>

但我收到错误:


由于发生内部服务器错误,该页面无法显示。


日志文件中没有任何内容可以帮助我获得有关哪些内容不起作用的提示。


翻阅古今
浏览 81回答 2
2回答

侃侃无极

我认为请求 URL 应该是https://www.example.com/image/123/spacer.gif而不是https://www.example.com/image/123/spager.gif。其次,如果你应用这个规则。请设置为<match url="^image/([0-9]+)/spacer.gif">代替<match url="^/image/([0-9]+)/spacer.gif">第一个斜杠“/”不包含在此段中。<rule name="email image tracker" enabled="true" stopProcessing="true">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <match url="^image/([0-9]+)/spacer.gif" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <action type="Rewrite" url="/image/index.php?id={R:1}" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </rule>此规则会将 /image/123/spacer.gif 重写为 /image/index.php?id=123。但是,由于 php 页面需要从https://www.example.com/image/123/spacer.gif请求资源 。由于循环,图像被损坏。我认为您可以尝试使用出站规则重写index.php 中的src 标记。

阿晨1998

我的配置文件位于图像文件夹内,因此将图像作为匹配的一部分删除。最后也<match ... />失踪了。/><?xml version="1.0" encoding="UTF-8"?><configuration>&nbsp; &nbsp; <system.webServer>&nbsp; &nbsp; &nbsp; &nbsp; <rewrite>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rules>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rule name="email_image_tracker" stopProcessing="true">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <match url="^([0-9]+)/spacer.gif" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <action type="Rewrite" url="/i/index.php?id={R:1}" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </rule>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </rules>&nbsp; &nbsp; &nbsp; &nbsp; </rewrite>&nbsp; &nbsp; </system.webServer></configuration>
打开App,查看更多内容
随时随地看视频慕课网APP