You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何防止Google索引我的Azure App Service子域名xxx.azurewebsites.net?

Hey there, great question—this is a super common scenario when launching Azure App Service sites, so let's break down your two concerns clearly:

How to Ensure Google Only Indexes xxx.com (Not xxx.azurewebsites.net)

To steer Google toward your custom domain and away from the default Azure subdomain, follow these actionable, SEO-friendly steps:

  • Add Canonical URL Tags: Every page on your site should include a canonical link pointing to its corresponding xxx.com URL. For example, on https://xxx.azurewebsites.net/contact, insert this in the <head> section:

    <link rel="canonical" href="https://xxx.com/contact">
    

    This explicitly tells search engines that the xxx.com version is the authoritative, preferred page.

  • Set Up Permanent 301 Redirects: Configure your Azure App Service to automatically send all traffic from xxx.azurewebsites.net to xxx.com. Here's how to do it in the Azure Portal:

    1. Open your App Service resource.
    2. Go to Settings > Custom domains.
    3. Under Redirect all traffic to the primary domain, select xxx.com as your primary custom domain and enable the redirect.
      301 redirects signal to search engines that the Azure subdomain has permanently moved to xxx.com, so they'll transfer any existing index weight and stop indexing the old domain.
  • Configure Google Search Console:

    1. Submit both xxx.com and xxx.azurewebsites.net as separate properties in Google Search Console.
    2. Verify ownership for both (you can use Azure DNS verification for a smooth setup).
    3. Set xxx.com as your preferred domain in the settings for both properties.
    4. Once the 301 redirect is fully active, use the Remove URLs tool in Search Console to request Google deindex the xxx.azurewebsites.net pages.
  • Block Crawlers on the Azure Subdomain: Create a robots.txt file exclusive to the xxx.azurewebsites.net domain (ensure this doesn't apply to xxx.com) with the following content:

    User-agent: *
    Disallow: /
    

    This tells all search crawlers to avoid indexing any pages on the Azure subdomain, adding an extra layer of protection.

Will Both xxx.com and xxx.azurewebsites.net Be Publicly Accessible After Launch?

Yes, by default, Azure App Service keeps the xxx.azurewebsites.net domain publicly accessible even after you add your custom xxx.com domain. That's why the 301 redirect step is so important—it ensures all users land on your branded domain instead of the Azure subdomain, and it reinforces your SEO priorities.

If you want to block direct access to the Azure subdomain entirely (instead of redirecting), you have two options:

  • Use Azure App Service's IP restrictions feature to allow only your internal/maintenance IPs to access xxx.azurewebsites.net
  • Add a rule in your app's code (e.g., in ASP.NET, Node.js, Python, etc.) to check the request host and return a 403 Forbidden response if it's xxx.azurewebsites.net

内容的提问来源于stack exchange,提问作者Ashkan S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:05:50