域名别名

域名基础
一个指向另一个域名的相同网站或内容的辅助域名。
← 返回词汇表

什么是域名别名?

域名别名是指指向与主域名相同网站、应用或内容的辅助域名。正确配置后,多个域名可以提供相同内容,让用户能够通过不同方式访问同一目的地。

域名别名与域名转发

特性域名别名域名重定向/转发
浏览器中的 URL显示别名域名显示主域名
提供的内容来自同一网站重定向后提供
HTTP 状态200 OK301/302 重定向
SEO 影响有重复内容风险汇总到主域名
DNS 设置A/AAAA 或 CNAME通常为 A/AAAA + 重定向
电子邮件可以共享邮件单独配置邮件
示例域名别名(URL 保持用户输入的内容):
User types: shop.example.com

Browser shows: shop.example.com

Content from: example.com (same server, same content)

域名重定向(URL 发生变化):
User types: shop.example.com

Browser redirects to: example.com

Browser shows: example.com

配置域名别名

DNS 配置

两个域名指向同一服务器:

# Primary domain

example.com. IN A 203.0.113.50

# Alias domain

example.net. IN A 203.0.113.50

shop-example.com. IN A 203.0.113.50

或者使用 CNAME 作为别名:

shop.example.com.   IN    CNAME    example.com.

Web 服务器配置

#### Apache

<VirtualHost *:80>

ServerName example.com

ServerAlias example.net shop.example.com www.example.net

DocumentRoot /var/www/example

<Directory /var/www/example>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

#### Nginx

server {

listen 80;

server_name example.com example.net shop.example.com;

root /var/www/example;

index index.html index.php;

location / {

try_files $uri $uri/ =404;

}

}

#### Cloudflare(CNAME 设置)

1. Add alias domain to Cloudflare

2. Create CNAME record:

shop.example.com → example.com

3. Enable "Flatten all CNAMEs" in DNS settings

4. Enable "Always Use HTTPS"

cPanel/WHM 配置

附加域名(创建新网站):
Domains → Addon Domains → Create New Domain
别名/停放域名(指向现有网站):
Domains → Aliases → Create a New Alias

Enter domain: shop.example.com

Alias for: example.com

常见使用场景

品牌变体

注册常见变体以防止域名抢注:

example.com    (primary)

example.net (alias)

example.org (alias)

example.io (alias)

拼写错误保护

捕获常见拼写错误:

example.com     (primary)

exampel.com (alias - typo)

exmple.com (alias - typo)

区域域名

在特定国家或地区顶级域名上提供相同内容:

example.com      (primary, global)

example.co.uk (alias, UK)

example.de (alias, Germany)

example.fr (alias, France)

注意:真正的国际化应使用 hreflang 标签和本地化内容。

营销活动

简短、易记的活动域名:

example.com              (primary site)

summerosale2024.com (alias for campaign landing page)

子域名别名

shop.example.com         (alias)

store.example.com (alias)

→ Both serve same e-commerce site

产品或服务品牌

companyname.com          (primary)

productname.com (alias)

域名别名的 SEO 考量

重复内容问题

搜索引擎可能将域名别名视为重复内容:

example.com/about

example.net/about

→ Same content, different URLs = duplicate

后果:权威度分散,排名降低。

规范链接标签

告诉搜索引擎哪个域名是主域名:

<!-- On all pages, regardless of domain -->

<link rel="canonical" href="https://example.com/page-path" />

这会告诉搜索引擎“将所有版本视为此 URL”。

首选方案:301 重定向

与其使用别名,不如重定向到主域名:

Apache(.htaccess)
RewriteEngine On

RewriteCond %{HTTP_HOST} !^example\.com$ [NC]

RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

Nginx
server {

listen 80;

server_name example.net shop.example.com;

return 301 https://example.com$request_uri;

}

这样会将所有 SEO 权威集中到主域名。

别名适用的场景

域名别名的电子邮件配置

共享邮件(同一邮箱)

为所有域名配置 MX 记录:

example.com.     IN    MX    10    mail.example.com.

example.net. IN MX 10 mail.example.com.

[email protected] and [email protected] → same mailbox

独立邮件(不同邮箱)

每个域名使用独立邮件:

example.com.     IN    MX    10    mail.example.com.

example.net. IN MX 10 mail.example.net.

[email protected][email protected] (different mailboxes)

别名之间的全收件箱邮件

接受发送到任意别名域名任意地址的邮件:

# Postfix virtual

@example.com [email protected]

@example.net [email protected]

@shop.example.com [email protected]

别名的 SSL/TLS 证书

多域名(SAN)证书

一张证书覆盖所有别名:

Certificate SANs:

example.com

www.example.com

example.net

www.example.net

shop.example.com

Let's Encrypt
certbot certonly --nginx \

-d example.com -d www.example.com \

-d example.net -d www.example.net \

-d shop.example.com

通配符证书

覆盖主域名的所有子域名:

*.example.com

→ Covers shop.example.com, blog.example.com, etc.

→ Does NOT cover example.net or other TLDs

独立证书

每个域名使用单独的证书:

example.com → cert1

example.net → cert2

最佳实践

所有别名始终使用 HTTPS

每个域名都应拥有有效的 SSL:

✓ https://example.com

✓ https://example.net

✓ https://shop.example.com

实施规范链接标签

即使提供相同内容,也要使用规范链接标签:

<link rel="canonical" href="https://example.com/current-page" />

优先考虑 301 重定向而非别名

为了 SEO,将别名重定向到主域名:

example.net → 301 redirect → example.com

shop.example.com → 301 redirect → example.com/shop

监控所有域名

将所有别名加入运行状况监控:

- Monitor DNS resolution for all aliases
  • Check SSL certificate validity
  • Verify web server responds correctly

品牌保持一致

使用别名时确保品牌一致:

Same logo, colors, navigation across all domains

Or clearly indicate relationship

记录别名策略

维护文档:

# domains.md
DomainTypePurposePoints To
example.comPrimaryMain siteServer A
example.netAliasBrand protectionServer A
shop.example.comAliasE-commerceServer A

测试域名别名

验证 DNS 解析

# Check all aliases resolve to same IP

dig example.com A +short

dig example.net A +short

dig shop.example.com A +short

# Should all return same IP or equivalent CNAME chain

测试 Web 服务器配置

# Verify server responds to all domains

curl -I https://example.com

curl -I https://example.net

curl -I https://shop.example.com

# Should all return 200 OK (or 301 if redirecting)

检查 SSL 证书

# Verify SSL covers all domains

echo | openssl s_client -servername example.net -connect example.com:443 2>/dev/null | openssl x509 -noout -text | grep DNS

# Should list all alias domains in SANs

SEO 验证

# Check canonical tags

curl -s https://example.net/page | grep "canonical"

# Should point to primary domain

<link rel="canonical" href="https://example.com/page" />

安全考量

域名劫持风险

域名越多,攻击面越大:

防钓鱼保护

注册防御性别名以防止钓鱼:

example.com (primary)

examp1e.com (homoglyph protection)

example-secure.com (defensive)

一致的安全策略

对所有别名应用相同的安全措施:

域名别名有助于品牌保护和用户访问,但必须谨慎配置,以避免 SEO 惩罚和安全风险。

将知识付诸实践

使用 DomScan 的 API 检查域名可用性、健康状态等。