Azure Web App Angular 未重定向到 www [英] Azure Web App Angular Not redirecting to www

查看:23
本文介绍了Azure Web App Angular 未重定向到 www的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 web.config 中有以下内容

I have the following in my web.config

<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
      <rewrite>
        <rules>
          <rule name="Angular" stopProcessing="true">
            <match url="^(.*)$" ignoreCase="false" />
            <conditions logicalGrouping="MatchAll">
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
            </conditions>
            <action type="Rewrite" url="index.html" appendQueryString="true"/>
          </rule>
          <rule name="Redirect to www" stopProcessing="true">
              <match url="(.*)" />
              <conditions trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="^mydomain.com$" />
              </conditions>
              <action type="Redirect" 
                url="{MapProtocol:{HTTPS}}://www.mydomain.com/{R:1}" />
            </rule>
        </rules>
          <rewriteMaps>
            <rewriteMap name="MapProtocol">
              <add key="on" value="https" />
              <add key="off" value="http" />
            </rewriteMap>
        </rewriteMaps>
      </rewrite>
    </system.webServer>
</configuration>

我的 angular.json 中的资产中有以下内容

I have the following in my assets in my angular.json

    "assets": [
      "src/favicon.ico",
      "src/assets",
      "src/web.config"
    ],

但我的应用没有重定向.

But my app does not redirect.

问题是我有一个适用于 www.mydomain.com 的应用服务托管证书设置

The issues is i have a App Service managed cert setup for www.mydomain.com

我有两个自定义域设置www.mydomain.com(这个允许我将绑定添加到应用服务证书)mydomain.com(未绑定,因为我无法添加证书)

I have two custom domains setup www.mydomain.com (this one allows me to add the binding to the app service cert) mydomain.com (is unbound as I cant add a cert)

所以我想我可以通过重定向来修复它以始终访问 www.但它似乎不起作用

So I thought I could fix it with the redirect to always go to www. but it does not seem to work

推荐答案

更新

您可以通过RewriterConfig 在web.config 文件中设置url 重写功能.更多详细信息,您可以在另一个 post 中查看我的答案.

You can RewriterConfig to set url rewrite function in web.config file. More details you can see my answer in anothor post .

私人

App Service集成的Web Server不能完全控制,这是PaaS产品的属性之一.

The Web Server integrated by App Service cannot have full control, which is one of the attributes of PaaS products.

App Service 只能使用 IIS 的部分功能.需要在/site/wwwroot(即你开发的项目的根目录)下的web.config文件中进行配置.所有可用的 IIS 功能只能通过 web.config 文件进行配置.

App Service can only use some functions of IIS. It needs to be configured in the web.config file under /site/wwwroot (that is, the root directory of the project you develop). All available IIS functions can only be configured through the web.config file.

解决方案:

• 尝试在 Web 配置文件中添加重定向规则.如果失败,只能使用应用网关的重写功能.

• Try to add redirect rule in the web config file. If it fails, you can only use the rewrite feature of the application gateway.

• 以下是应用网关的一些关于重写特性的文档,供您参考.

• The following are some documents of Application Gateway about rewrite feature for your reference.

重定向

重定向网络流量

疑难解答--应用服务问题

这篇关于Azure Web App Angular 未重定向到 www的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆