2016-06-30 53 views
0

我有2個域名指向同一個應用程序一把umbraco:重新寫舊的URL到新的URL Asp.Net

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都是分配給該站點的主機名。

回答

0
<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> 
+1

注意:在輸入[OLD URL]時,不要包含** http:// **,因爲這樣做不起作用。 – Vikrant