在 Azure 上托管的 wordpress 网站上启用 SSL

在 Azure 上托管的 wordpress 网站上启用 SSL

我有一个网站正在运行Azure,它是一个wordpress网站。从Azure 文档他们说的只是复制并粘贴 web.config 文件中的示例

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Force HTTPS" enabled="true">
          <match url="(.*)" ignoreCase="false" />
          <conditions>
            <add input="{HTTPS}" pattern="off" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

我将规则部分复制到了我现有的 web.config 文件中。但网站甚至没有加载,加载时出现错误。虽然我已经添加了 SSL,但网站正在 evercam.io 上运行,https://www.evercam.io。我需要的是当有人访问 evercam.io 时,否则它应该通过 HTTPS 链接而不是简单的链接。

我的运行配置文件是

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\
temp\IIS Temporary Compressed Files">
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
  <dynamicTypes>
    <add mimeType="text/*" enabled="true"/>
    <add mimeType="message/*" enabled="true"/>
    <add mimeType="application/javascript" enabled="true"/>
    <add mimeType="*/*" enabled="false"/>
  </dynamicTypes>
  <staticTypes>
    <add mimeType="text/*" enabled="true"/>
    <add mimeType="message/*" enabled="true"/>
    <add mimeType="application/javascript" enabled="true"/>
    <add mimeType="*/*" enabled="false"/>
  </staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
<rewrite>
  <rules>              
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^(.*)$" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}.php" matchType="IsFile" ignoreCase="false" />
      </conditions>
      <action type="Rewrite" url="{R:1}.php" />
    </rule>
    <rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="true">
      <match url="*" />
      <conditions>
        <add input="{CACHE_URL}" pattern="*://www.*" />
      </conditions>
      <action type="Redirect" url="{C:1}://{C:2}" redirectType="Permanent" />
    </rule>
    <rule name="Show vendors list" stopProcessing="true">
      <match url="^/?vendors/$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      </conditions>
      <action type="Rewrite" url="/vendors.php" />
    </rule>
    <rule name="Show vendor details" stopProcessing="true">
      <match url="^/?vendors/([^/]+)$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      </conditions>
      <action type="Rewrite" url="/vendors.php?{R:1}" />
    </rule>
    <rule name="Show models list" stopProcessing="true">
      <match url="^/?models/$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      </conditions>
      <action type="Rewrite" url="/models.php" />
    </rule>
    <rule name="Show model details" stopProcessing="true">
      <match url="^/?models/([^/]+)$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      </conditions>
      <action type="Rewrite" url="/models.php?{R:1}" />
    </rule>
    <rule name="Show public assets summary" stopProcessing="true">
      <match url="^/?public/$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      </conditions>
      <action type="Rewrite" url="/public/index.php" />
    </rule>
    <rule name="Show public camera details" stopProcessing="true">
      <match url="^/?public/cameras/([^/]+)$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      </conditions>
      <action type="Rewrite" url="/public/cameras/?{R:1}" />
    </rule>
  </rules>
</rewrite>
<staticContent>
  <clientCache cacheControlMaxAge="28.00:00:00" cacheControlMode="UseMaxAge"/>
  <remove fileExtension=".woff" /> <!-- In case IIS already has this mime type -->
  <remove fileExtension=".json" /> <!-- In case IIS already has this mime type -->
  <remove fileExtension=".mp4" /> <!-- In case IIS already has this mime type -->
  <remove fileExtension=".svg" /> <!-- In case IIS already has this mime type -->
  <mimeMap fileExtension=".json" mimeType="application/json" />
  <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
  <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
  <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<caching>
  <profiles>
      <add extension=".php" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="00:01:00:00" />
      <add extension=".ttf" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="28:00:00:00" />
      <add extension=".gif" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="28:00:00:00" />
      <add extension=".jpg" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="28:00:00:00" />
      <add extension=".png" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="28:00:00:00" />
      <add extension=".js" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="28:00:00:00" />
      <add extension=".css" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="28:00:00:00" />
  </profiles>
</caching>
<httpProtocol>
    <customHeaders>
    <remove name="Vary"></remove>
    <add name="Vary" value="Accept-Encoding"></add>
    </customHeaders>
  </httpProtocol>
<httpErrors>
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" prefixLanguageFilePath="" path="/404.php" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>

任何帮助都将不胜感激

相关内容