问题描述
试图阻止在Google搜索结果上显示的“ azurewebsites” URL,通常我会在网络配置中简单地添加一个重定向规则,如下所示:
<rule name="disable Azure Domain" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="*.azurewebsites.net" />
</conditions>
<action type="Redirect" url="https://www.mysitedomain.org{REQUEST_URI}" redirectType="Permanent" />
</rule>
但是,在Azure前门后的特定站点上使用此重定向时,会导致该站点返回404。我假设前门必须使用azurewebsites url,因此这不是可行的解决方案。 / p>
欢迎提出任何建议。
解决方法
我认为前门必须使用azurewebsites网址,因此这不是可行的解决方案。
这不是事实。在前门中创建后端时,可以选择“自定义主机”并指定为应用程序服务配置的自定义域。 。
因此解决方案如下:
- 将custom domain用于您的应用程序服务。因此,您的网站将类似于siteA.mysitedomain,siteB.mysitedomain等。
- 将后端作为这些自定义域添加到前门。
- 最后在web.config中使用重定向规则,如下所示。重定向到前门URL(您也可以在use custom domain那里)。这样可以确保即使有人使用.azurewebsites.net URL指向您的网站,他们也将被重定向到前门入口点。最终,搜索引擎将无法在azurewebsites.net上建立索引。
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect rquests to default azure websites domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^yoursite\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="http://www.yoursite.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
,
找到一个相对简单的解决方案是,简单地在类型为“服务标签”的应用程序服务上添加IP限制,然后选择AzureFrontDoor.Backend