IIS URL 重写重定向到图像以跟踪电子邮件浏览量
IIS URL Rewrite redirect to image to track email views
我正在尝试根据请求图像的文件夹名称构建电子邮件跟踪器。
示例:
https://www.example.com/image/123/spager.gif
需要变成这个
https://www.example.com/image/index.php?id=123
在 return 中将提供 spacer.gif 图片。
这可行吗?如果是,我错过了什么?
太好了,我得到了这个:
web.config:
<rule name="email image tracker">
<match url="^/image/([0-9]+)/spacer.gif">
<action type="Rewrite" url="/image/index.php?id={R:1}" />
</rule>
index.php:
<?php
header('Content-type: image/gif');
$png_image = imagecreate(150, 150);
imagecolorallocate($png_image, 15, 142, 210);
?>
但我收到错误消息:
The page cannot be displayed because an internal server error has occurred.
并且日志文件中没有任何内容可以帮助我获得有关不工作的提示。
我认为请求URL应该是https://www.example.com/image/123/spacer.gif instead of 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">
<match url="^image/([0-9]+)/spacer.gif" />
<action type="Rewrite" url="/image/index.php?id={R:1}" />
</rule>
此规则会将 /image/123/spacer.gif 重写为 /image/index.php?id=123。但是,由于 php 页面需要从 https://www.example.com/image/123/spacer.gif 请求资源。图像因循环而损坏。
我想你可以尝试用出站规则重写 index.php 内的 src 标签。
我在图像文件夹中有配置文件,所以将图像作为匹配的一部分。
另外 <match ... />
缺少 />
最后。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="email_image_tracker" stopProcessing="true">
<match url="^([0-9]+)/spacer.gif" />
<action type="Rewrite" url="/i/index.php?id={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我正在尝试根据请求图像的文件夹名称构建电子邮件跟踪器。
示例:
https://www.example.com/image/123/spager.gif
需要变成这个
https://www.example.com/image/index.php?id=123
在 return 中将提供 spacer.gif 图片。
这可行吗?如果是,我错过了什么?
太好了,我得到了这个:
web.config:
<rule name="email image tracker">
<match url="^/image/([0-9]+)/spacer.gif">
<action type="Rewrite" url="/image/index.php?id={R:1}" />
</rule>
index.php:
<?php
header('Content-type: image/gif');
$png_image = imagecreate(150, 150);
imagecolorallocate($png_image, 15, 142, 210);
?>
但我收到错误消息:
The page cannot be displayed because an internal server error has occurred.
并且日志文件中没有任何内容可以帮助我获得有关不工作的提示。
我认为请求URL应该是https://www.example.com/image/123/spacer.gif instead of 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">
<match url="^image/([0-9]+)/spacer.gif" />
<action type="Rewrite" url="/image/index.php?id={R:1}" />
</rule>
此规则会将 /image/123/spacer.gif 重写为 /image/index.php?id=123。但是,由于 php 页面需要从 https://www.example.com/image/123/spacer.gif 请求资源。图像因循环而损坏。
我想你可以尝试用出站规则重写 index.php 内的 src 标签。
我在图像文件夹中有配置文件,所以将图像作为匹配的一部分。
另外 <match ... />
缺少 />
最后。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="email_image_tracker" stopProcessing="true">
<match url="^([0-9]+)/spacer.gif" />
<action type="Rewrite" url="/i/index.php?id={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>