[英]IIS 10 Rewrite with Parameters
我正在尝试使用参数解决 IIS 重定向(http + https)。
源 URL:subdomain.example.com
我使用了以下 web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirect to HTTPS" enabled="true" patternSyntax="ExactMatch" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="(.*)" />
</conditions>
<action type="Redirect" url="https://target.com/com/en/products-z/xxx/yyy/wow-fan.html?utm_source=oldvanity&utm_medium=redirect&utm_campaign=oldvanity" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<httpRedirect enabled="true" destination="https://target.com/com/en/products-z/xxx/yyy/wow-fan.html?utm_source=oldvanity&utm_medium=redirect&utm_campaign=oldvanity" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>
使用此 web.config 无法访问,并发生内部服务器错误。
HTTP/1.1 500 Internal Server Error
Content-Length: 1192
Content-Type: text/html
Server: Microsoft-IIS/10.0
如果我将 web.config 中的目标编辑为: Target-URL: https://target.com/com/en/products-z/xxx/yyy/wow-fan.ZFC35FDC70D5FC69D769883A822
它工作正常。
我的 web.config 不适用于 Targetlink 中的参数“&utm_medium=redirect&utm_campaign=oldvanity”。
我也在 targetlink 的末尾尝试了 $Q$A,但没有奏效。
非常感谢任何帮助。 有人知道如何正确重定向带有 & 的 Target 吗?
非常感谢你,最好的问候马克斯
您可以尝试以下规则:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirect to HTTPS" enabled="true" patternSyntax="ExactMatch" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="subdomain.example.com" />
</conditions>
<action type="Redirect" url="https://target.com/com/en/products-z/xxx/yyy/wow-fan.html?utm_source=oldvanity&utm_medium=redirect&utm_campaign=oldvanity" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
再次感谢你的帮助!
我现在已经结合了我们的 web.config 并且它可以工作::D 还添加了 HSTS 支持
@Jalpa - 非常感谢您的帮助; @Lex Ki - 也谢谢你 - 如何读出服务器错误是我迄今为止在 Windows/IIS 中忽略的重要一点;)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirect to HTTPS" enabled="true" patternSyntax="ExactMatch" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTPS}" pattern="(.*)" />
</conditions>
<action type="Redirect" url="https://target.com/com/en/products-z/xxx/yyy/wow-fan.html?utm_source=oldvanity&utm_medium=redirect&utm_campaign=oldvanity" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
<outboundRules>
<rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
<match serverVariable="RESPONSE_Strict_Transport_Security"
pattern=".*" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Rewrite" value="max-age=31536000; includeSubDomains; preload" />
</rule>
</outboundRules>
</rewrite>
<httpRedirect enabled="true" destination="https://target.com/com/en/products-z/xxx/yyy/wow-fan.html?utm_source=oldvanity&utm_medium=redirect&utm_campaign=oldvanity" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>
一切顺利
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.