NewSubDomain.newexample.com/route?newID =34563456456
我需要包括的这些URL重定向中有15个。它们是特定的和宽容的。
我已经阅读了一种方法可以在Web中进行此操作。 Cheers
我已经阅读了一种方法可以在Web中进行此操作。
是的,可以使用web.config
重定向多个URL。
感谢@thomas ardal的明确解释。请参阅此文件:Web.config
您可以在
<rule>
部分中添加多个元素以匹配不同的URL并相应地重定向。
<rules>
现在将应用程序部署到Azure应用程序服务后,当您从子域重定向时,您必须在Azure中进行配置。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="RedirectRoute1" stopProcessing="true">
<match url="route" />
<conditions>
<add input="{HTTP_HOST}" pattern="^subdomain\.example\.com$" />
<add input="{QUERY_STRING}" pattern="someID=123&otherId=4356" />
</conditions>
<action type="Redirect" url="https://newsubdomain.newexample.com/route?newID=34563456456" redirectType="Permanent" />
</rule>
<rule name="RedirectRoute2" stopProcessing="true">
<match url="old-page" />
<conditions>
<add input="{HTTP_HOST}" pattern="^subdomain\.example\.com$" />
</conditions>
<action type="Redirect" url="https://newsubdomain.newexample.com/new-page" redirectType="Permanent" />
</rule>
<rule name="RedirectRoute3" stopProcessing="true">
<match url="another-route" />
<conditions>
<add input="{HTTP_HOST}" pattern="^subdomain\.example\.com$" />
</conditions>
<action type="Redirect" url="https://newsubdomain.newexample.com/different-route" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
->验证后,将其绑定到应用程序。
doc1
和doc2
了解将子域映射到Azure网站。 参考链接。,您也可以将
subdomain.example.com
用作替代方法samameweb.config:
Rewrite Map
通过上述方法,您可以使用
<rewriteMaps>
<rewriteMap name="RedirectsMap">
<add key="subdomain.example.com/route?someID=123&otherId=4356" value="https://newsubdomain.newexample.com/route?newID=34563456456" />
<add key="subdomain.example.com/old-page" value="https://newsubdomain.newexample.com/new-page" />
<add key="subdomain.example.com/another-route" value="https://newsubdomain.newexample.com/different-route" />
</rewriteMap>
</rewriteMaps>