我在Microsoft上托管一个站点,我需要将一个重定向从旧域(domain1.com)添加到一个新域(www.domain2.com)。然而,我遇到的问题是,重定向在不安全的url上运行得很好:
http://domain1.com -> https://www.domain2.com http://www.domain1.com -> https://www.domain2.com
但是,它在安全网址上不能正常工作:
https://domain1.com -> https://www.domain2.com https://www.domain1.com -> https://www.domain2.com
所发生的情况是,我得到一个证书警告,即给定的证书对此域无效。如果我接受警告,重定向就会发生在新域上。
这向我展示了一切正常工作,只是ssl是在浏览器中重定向发生之前协商的,而且因为在我收到警告的第一个域上没有ssl证书。这是正确的吗?
这里有什么东西我遗漏了吗?有更好的方法吗?我需要两个域上的ssl证书吗?
这是我的web.config文件,您可以看到我的配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!-- Don't show directory listings for URLs which map to a directory. -->
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="Protect files and directories from prying eyes" stopProcessing="true">
<match url="\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$" />
<action type="CustomResponse" statusCode="403" subStatusCode="0" statusReason="Forbidden" statusDescription="Access is forbidden." />
</rule>
<rule name="Force simple error message for requests for non-existent favicon.ico" stopProcessing="true">
<match url="favicon\.ico" />
<action type="CustomResponse" statusCode="404" subStatusCode="1" statusReason="File Not Found" statusDescription="The requested file favicon.ico was not found" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
</rule>
<!-- Rewrite URLs of the form 'x' to the form 'index.php?q=x'. -->
<rule name="Short URLs" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
</rule>
<rule name="Redirect old-domain to new-domain" stopProcessing="true" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?domain1.com$" />
</conditions>
<action type="Redirect" url="https://www.domain2.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="https://www.domain2.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
<!-- Force HTTPS Starts -->
<rule name="Force HTTPS" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://www.domain2.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
<!-- Force HTTPS Ends -->
</rules>
</rewrite>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />
</httpErrors>
<defaultDocument>
<!-- Set the default document -->
<files>
<remove value="index.php" />
<add value="index.php" />
</files>
</defaultDocument>
</system.webServer>
</configuration>发布于 2016-08-29 13:46:51
您将能够将非安全URL重定向到HTTP/HTTPs。但是,除非安装了有效的SSL证书,否则无法将HTTPS (https://domain1.com)重定向到任何HTTP/HTTPs (https://www.domain2.com)。
http://domain1.com -> https://www.domain2.com [YES, with or without SSL]
http://www.domain1.com -> https://www.domain2.com [YES, with or without SSL]和,
https://domain1.com -> https://www.domain2.com [Required Valid SSL certificate for domain1.com]
https://www.domain1.com -> https://www.domain2.com [Required Valid SSL for domain1.com]这就是为什么您会收到错误,因为“给定的证书对此域无效”,因为您没有有效的证书。请注意,如果希望旧URL在新HTTPS URL上重定向,则必须在旧域和新域上安装SSL证书。
发布于 2022-01-03 21:21:46
https://stackoverflow.com/questions/39137952
复制相似问题