When you visit a website, you may notice the URL in the search bar changes slightly based on your location on the site or which web page you’re viewing.

For example, you can visithubspot.comto view and access the tools and services offered. Or, you can visitwww.eigoj.comto access the section of our website that serves blog content. Although the URL changes slightly, you’re still on HubSpot’s website, under HubSpot’s domain.

在本文中,我们将研究URL的一部分does更改 - 称为子域,以及为什么这是什么。

Download Now: Free HTML & CSS Hacks

域名通常有两个部分:顶级域(TLD)is the extension, such as。comor。org,和二级域(SLD)是域名的独特部分,通常是业务或品牌名称。在里面hubspot.com例子,com是TLD和hubspotis the SLD.

subdomainis what goesthe SLD. The most common subdomain is万维网,代表万维网。该子域包含网站的主页及其最重要的页面。这万维网subdomain is so widely used that most域注册商include it with domain name purchases.

子域are also commonly used to separate a section of a website from the main site. For example,www.eigoj.comandshop.hubspot.comdirect to our blog and online store respectively.

当我们在开始时将域名和子域与协议(网站的HTTP或HTTPS)和一个可选的文件路径分组时,我们有一个完整的URL:

anatomy of a web address containing a subdomain

What is a subdomain used for?

子域使您可以简单地组织网站的各种功能,同时也使用户更容易找到这些不同的功能。

这样考虑:如果您举办聚会,则需要为客人提供您的地址。TLD将是您居住的城市,而SLD将是您的电话号码和街道名称。如果您住在公寓楼,则需要更具体地说,以便您的客人知道要敲响的公寓。您的公寓号类似于子域,这是一个专门用于您的居住空间的大楼的特定部分。

If you plan to add more functions to your website, such as a store, a forum, or a blog, you might add a subdomain to your domain to separate these functions off from your main website.

You can also use subdomains to create localized content. For example, if you run a restaurant chain with multiple locations, customers can visitwww.myrestaurant.comfor all-encompassing content. Or, customers looking for the menu at your Nashville, Tennessee location can access this information vianashville.myrestaurant.com

亚域示例

If you’re looking to create a subdomain on your website but aren’t sure what that would look like, refer to the万维网。hubspot.comandwww.eigoj.comexample mentioned above.

By separating the HubSpot Blog from the rest of the website, it makes it obvious to visitors where they’re located on the HubSpot website as a whole. This is helpful considering万维网。hubspot.com专注于HubSpot产品线,而www.eigoj.com包含不一定与HubSpot产品有关的文章。用子域将两者彼此分开可以使一切都井井有条,并帮助访客找到所需的东西。

example of a subdomain on hubspot.com

这是另一个例子:除了其在线商店出售新产品,户外服装品牌Patagoniaalso resells its used clothing through the穿着program. When we visit both of these links, we see that万维网。patagonia.comencompasses the Patagonia store (as well as other initiatives by the brand) and thatwornwear.patagonia.comis used for the Worn Wear section.

example of a subdomain on patagonia.com

网站也可以以其他方式使用子域,例如表示语言或区域。Wikipedia用文章来做到这一点。例如,en子域是指本文用英语编写,es指示西班牙语,依此类推。

example of a subdomain on wikipedia.com

Here’s a fun subdomain trick: Try replacing the subdomain for a Wikipedia article with简单的。您可能会为学习语言和有不同需求的人看到本文的简化英文版本。

example of a subdomain on wikipedia.com

Now let’s take a look at how you can go about creating a subdomain on your own website.

无论您想使用什么子域,都可以在您的帮助下创建一个虚拟主机提供者。

例如,HubSpot的CMS,CMS集线器— which you can test out with a免费14天试用— makes it easy to将您的内容托管在一个子域中per content tool you use (e.g. blog, landing page, website page) for一个品牌领域

It’s important to note that these features are specific to HubSpot’s CMS. Your hosting provider as well as the service through which you obtained your domain name are unique.

同样,we work through the following steps, keep in mind that they may differ slightly depending on your service.

1. Name your subdomain.

First, think of a subdomain name that best fits the section of the site you’re assigning. Common subdomains include博客,store,shop,support,帮助, 和events

这re’s no need to overthink this — pick a name that succinctly describes this part of your site, and limit it to one word if you can. That way, your URL will look clean and familiar to visitors, even with the extra name tacked on.

2. Log into your cPanel.

To begin creating your subdomain, log into your hosting provider’s file manager, which is likely to becpanel。每个托管提供商都有一个唯一的登录名和设置,但您的屏幕应该看起来像这样。

login to your cpanel to create a subdomain

Image Source

3. Navigate to and enter your subdomain.

现在您要导航到子域orAdd Subdomains。Here you can begin to enter your subdomain of choice. Add the subdomain, and be sure your primary domain name is selected as well.

导航到并输入您的子域名

Image Source

4.创建新的DNS记录。

创建域后,您需要添加一个新的域名系统(DNS)记录。导航到DNS并选择Add(or a similar command). Select what you want your subdomain to connect to, whether it’s anIP address,连接到目标主机名,服务器名称或通配符域的IP地址。

Add DNS to create a subdomain

Image Source

5.单击创建并等待您的子域解决。

Finally, clickCreate或类似的推荐,等待你subdomain to resolve. It typically takes anywhere from 30 minutes to 24 hours for your subdomain to be implemented and functional on your website.

Add a subdomain to your site

如果您不确定是否应该在您的下发布特定页面万维网subdomain or under a different subdomain, think about the primary goals of your website. Pages related to this goal should fall under万维网, 和consider placing other pages under a custom subdomain if there are enough to make up a substantial part of your site. A collection of a few pages probably doesn’t need its own subdomain.

For example, if you run an online store and write the occasional blog post, you can usewww.mywebsite.comfor your store and博客。mywebsite.com对于您的博客部分。相反,如果您主要发布博客并在网站上出售一些商品,请使用www.mywebsite.com为您的博客和store.mywebsite.comfor the ecommerce side.

By implementing subdomains on your website, you can create separate sections of content and services for your website without having to create new domain names for each part. Subdomains will also make it easier for users to find what they need, all in one place. If it improves your visitors’ experience, it’s likely a step worth taking.

New Call-to-action

CSS简介

Originally published Feb 12, 2021 7:00:00 AM, updated October 28 2021

Topics:

虚拟主机