![](/img/trans.png)
[英]Redirect from HTTP to HTTPS and to a new domain with C# MVC in IIS7.5
[英]Rewrite from local path to external domain - C# MVC IIS 7.5 URL
我无法在MVC应用程序中进行URL重写,因为我需要将来自https://www.thisdomain.com/assets/ *的所有请求定向到位于https://www.thatdomain.com/assets的等效请求/ *例如
<link rel="stylesheet" href="/assets/css/app.css">
从https://www.thatdomain.com/assets/css/app.css加载资源
我目前在web.config中
<system.webServer>
<rewrite>
<rules>
<rule name="Map Assets" stopProcessing="true">
<match url="assets/(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.otherdomain.com/assets/$" />
</conditions>
<action type="Rewrite" url="/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
并将其添加到我的RouteConfig.cs中
routes.IgnoreRoute("assets/");
网址重写已安装在服务器上。
任何帮助将不胜感激。
一些问题:那些“ www.thisdomain.com”和“ www.otherdomain.com”托管在同一服务器上吗? 您确定要“重写”,而不是“重定向”吗?
我什至不确定是否可以重写到另一个域。 您可以重写资源路径或名称,但是域对我而言意义不大。 但是重定向可以配置如下:
<rewrite>
<rules>
<rule name="Map Assets" stopProcessing="true">
<match url="assets/(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.thisdomain.com" />
</conditions>
<action type="Redirect" url="www.otherdomain.com/assets/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.