web配置http到https重定向异常

时间:2016-05-13 21:59:37

标签: javascript asp.net redirect iis web-config

我在GoDaddy有两个域:

www.mymaindomain.com

www.mysecondarydomain.com

主域存储在根ftp文件夹中,辅助域存储在单独的文件夹“second”中。 我已经为我的主域购买了SSL证书,并在web.config中将http应用于https重定向,如GoDaddy帮助中所述:

<configuration> 
	<system.webServer> 
		<rewrite> 
			<rules> 
				<rule name="HTTP to HTTPS redirect" stopProcessing="true"> 
					<match url="(.*)"></match> 
					<conditions> 
						<add input="{HTTPS}" pattern="off" ignoreCase="true"></add> 

					</conditions> 
					<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}"></action> 
				</rule> 
				</rules> 
		</rewrite> 
	</system.webServer> 
</configuration>

问题是,辅助域的流量也会重定向到https,用户会收到安全警报。 我试图为辅助域添加例外如下:

<add input="{R:1}" pattern="second" negate="true"></add> 
我也尝试过:

<add input="{REQUEST_URI}" negate="true" pattern="[a-zA-Z0-9.\/?=_\-\&%:]*[s][e][c][o][n][d][a-zA-Z0-9.\/?=_\-\&%]*" ignoreCase="true"></add> 

他们没有工作。

花了一整天后,我无法弄清楚如何将辅助域从http排除到https重定向规则。 我将不胜感激任何帮助。

2 个答案:

答案 0 :(得分:0)

mymaindomain的文件夹更改为ftp根文件夹中的文件夹,将同级文件更改为文件夹mysecondarydomain

答案 1 :(得分:0)

我已用以下代码行解决了这个问题:

<add input="{HTTP_HOST}" pattern="mysecondarydomain\.com" negate="true" ignoreCase="true"></add>