大网数据广告活动
网站运营与故障问答

Why do browsers know to lookup the `www` record if DNS query for @ gets NXDOMAIN?

· 52CE 我爱测

Description If I dig for businessbrief.xyz , I get no results, but the subdomain www returns an address. Entering businessbrief.xyz into any browser's address bar goes to a valid web address. Data Note that dig for @ returns no r…

问题原文

原帖链接 · Ross Jacobs · CC BY-SA 4.0

Description

If I dig for businessbrief.xyz, I get no results, but the subdomain www returns an address. Entering businessbrief.xyz into any browser's address bar goes to a valid web address.

Data

Note that dig for @ returns no results and dig for www does:

$ dig businessbrief.xyz +short

$ dig www.businessbrief.xyz +short
target.substack-custom-domains.com.
104.18.21.132
104.18.20.132

As an aside, the IPs listed for www are Cloudflare revers proxy IPs.

But if enter this domain into Chrome, Firefox, and Safari, the www record is automatically requested.

We see this in Chrome's Devtools like so, where the first request for businessbrief.xyz is to www.businessbrief.xyz:

I also see the same behavior in Wireshark, where no DNS requests are sent for businessbrief.xyz, but a DNS request is sent for www.businessbrief.xyz.

As some people are not able to replicate this (and in case this website changes), I've attached a webm of this happening in Chrome.

Question

Why do browsers redirect businessbrief.xyz to https://www.businessbrief.xyz?

EDIT: Related SO question scoped to just firefox: https://stackoverflow.com/questions/10186383/

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

Browsers generally have heuristics built in to add missing www. from domain names, but it isn't something you should rely on:

  • Browsers typically have a setting to turn off this "www fix up."
  • Even when browsers do add www. it appears they don't so when the URL starts with https:// (like https://example.com), probably for security reasons.
  • Not every browser and search engine bot will implement this feature. It isn't in a specification that I've been able to find.

You should ensure that your non-www domain resolves to a server and redirects appropriately. Relying on clients to automatically do so with their heuristics is going to lead to failures in many cases.


This site explains some of the browser setting that control auto-www:

Firefox

In about:config the setting browser.fixup.alternate.prefix is set to www. by default. You can prevent Firefox from adding the www by setting browser.fixup.alternate.enabled to false.

Chrome

Chrome implements adding www. as part of its "prediction service." You can disable that in settings under "Settings" > "Show advanced settings" and unchecking the option that starts with "Use a prediction service."

Edge and Internet Explorer

It is controlled by a setting in "Internet Options" > "General tab" > "Appearance" > "Languages" where you need to check the setting starting "Do not add 'www'."

Safari

Safari must have a setting for this because some users report an added www. and some do not. However, I have not been able to identify which setting controls the behavior.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2021-12-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。