2013-10-23 24 views
1

我想我的网站从https://localhost重定向(但与IP写的,像https://10.0.7.8)像https://mysite.com从HTTPS使用IIS URL重写到另一个HTTPS

我目前的配置另一个HTTPS位置是:

<rewrite> 
    <rules> 
    <rule name="Rewrite to mysite.com" enabled="true" stopProcessing="true"> 
     <match url="(.*)" /> 
     <action type="Redirect" url="https://mysite.com/{R:0}" redirectType="Permanent" /> 
     <conditions logicalGrouping="MatchAll"> 
     <add input="{HTTP_HOST}" pattern="https://10.0.7.8*" /> 
     </conditions> 
    </rule> 
    </rules> 
</rewrite> 

,当我访问https://10.0.7.8它不会去https://mysite.com,它停留在https://10.0.7.8

任何想法,我究竟做错了什么?

回答

2

你需要在2个条件的https部分从IP分裂:

<rewrite> 
    <rules> 
    <rule name="Rewrite to mysite.com" enabled="true" stopProcessing="true"> 
     <match url="(.*)" /> 
     <conditions logicalGrouping="MatchAll"> 
     <add input="{HTTP_HOST}" pattern="^10\.0\.7\.8$" /> 
     <add input="{HTTPS}" pattern="^ON$" /> 
     </conditions> 
     <action type="Redirect" url="https://mysite.com/{R:0}" redirectType="Permanent" /> 
    </rule> 
    </rules> 
</rewrite> 

此外,10.0.7.8需要编写10\.0\.7\.8因为需要.转义,因为它是一个特殊字符。

+1

完美的作品!非常感谢的人! –