将旧 url 重写为新 url Asp.Net
Re-write old url to new url Asp.Net
我有 2 个域指向同一个 Umbraco 应用程序:
oldexample.com
newexample.com
我希望我的应用程序将 URL 更改为:
oldexample.com/...
TO
newexample.com/...
当人们访问 oldexample.com。
在我的 web.config 中,我已经放置了这个,但没有效果:
<rewrite>
<rules>
<rule name="Redirect old-domain to new-domain" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^oldexample.com$" />
</conditions>
<action type="Redirect" url="http://www.newexample.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
<add input="{HTTP_HOST}" negate="true" pattern="localhost" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
我做错了什么?
// 应用程序托管在 Azure 网站中。 两个 URL 都是分配给该站点的主机名。
<rewrite>
<rules>
<rule name="Redirect oldexample.com to newexample.com" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^www\.oldexample\.com$" />
<add input="{HTTP_HOST}" pattern="^oldexample\.com$" />
</conditions>
<action type="Redirect" url="http://www.newexample.com/{R:1}" />
</rule>
</rules>
</rewrite>
我有 2 个域指向同一个 Umbraco 应用程序:
oldexample.com
newexample.com
我希望我的应用程序将 URL 更改为:
oldexample.com/...
TO
newexample.com/...
当人们访问 oldexample.com。
在我的 web.config 中,我已经放置了这个,但没有效果:
<rewrite>
<rules>
<rule name="Redirect old-domain to new-domain" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^oldexample.com$" />
</conditions>
<action type="Redirect" url="http://www.newexample.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
<add input="{HTTP_HOST}" negate="true" pattern="localhost" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
我做错了什么?
// 应用程序托管在 Azure 网站中。 两个 URL 都是分配给该站点的主机名。
<rewrite>
<rules>
<rule name="Redirect oldexample.com to newexample.com" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^www\.oldexample\.com$" />
<add input="{HTTP_HOST}" pattern="^oldexample\.com$" />
</conditions>
<action type="Redirect" url="http://www.newexample.com/{R:1}" />
</rule>
</rules>
</rewrite>