网站的 http://website.com 和 http://www.website.com URL 有什么区别?

发布于 2024-09-10 00:30:54 字数 584 浏览 9 评论 0原文

可能的重复:
网址中包含“www”有什么意义?

您好,我几乎没有拥有网站的经验,但我愿意学习此过程的所有知识。然而我很沮丧,因为我经常被简单的问题所困扰。

我刚刚上传了我的第一个 index.html 页面,该页面基本上是背景颜色和标题图像。我将我的图标放在 public_html 目录中,紧邻index.html。我立即注意到它不起作用。我还注意到我在地址栏中输入了 http://website.com 。我在“网站”之前输入“www”,然后图标就出现了。我回击,图标又变成空白了。非 www 版本的网站和 www 版本的网站有什么区别?为什么网站图标不显示?还有哪些其他差异?我应该像许多专业网站那样禁用非 www 网站吗?我该怎么做?如果有的话,有哪些优点和缺点?

谢谢。

Possible Duplicate:
What’s the point in having “www” in a URL?

Hello, I have little to no experience owning a website but I am willing to learn all that there is to this process. However I am frustrated because I am constantly blocked by simple problems.

I just uploaded my first index.html page which is basically a background color and a title image. I put my favicon in the public_html directory right next to index.html. I immediately notice that it does not work. I also notice that I have typed http://website.com in the URL bar. I type "www" before "website" and the favicon shows up. I hit back and the favicon is blank again. What is the difference between the non-www version of the site and the www version of the site? Why does the favicon not show up? What other differences are there? Should I disable the non-www site like many professional sites seem to do? How do I do this? What are the advantages and disadvantages, if any?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

愛上了 2024-09-17 00:30:54

www 子域只是网站之间的约定,用于指示该地址指向万维网服务器。

例如,

  • google.com 是以下域名的顶级域名
    谷歌公司。
  • www.google.com 表明这是
    万维网的域名,
  • ftp.google.com 表明这是
    可能是 ftp 服务器。

但由于这只是一种约定,并且普通用户主要使用 www 来访问互联网,因此大多数服务器都会配置其 http://domain.com http://www.domain.com 的别名。

为什么您网站上的图标仅显示 www 版本而不是 topdomain,取决于您的 html 和服务器配置。您可以发布一些代码或链接到您的网站吗?

The www-subdomain is just a convention amongst websites to indicate this address points to a World Wide Web server.

For example,

  • google.com is the top domainname of
    the Google company.
  • www.google.com indicates this is the
    domain name for the World Wide Web,
  • ftp.google.com indicates this is
    probably an ftp-server.

But as it is just a convention, and the average user uses the internet mainly for www, most servers configure their http://domain.com to be aliases to http://www.domain.com.

Why the favicon on your site only shows up for the www-version and not for the topdomain, depends on your html and your server configuration. Can you post some code or link to your site?

悟红尘 2024-09-17 00:30:54

完全限定域名不同。所以它们是不同的网站。

通常,两个主机名将指向相同的 IP 地址,并且服务器将被配置为为两者提供相同的内容或从一个主机名重定向到另一个主机名。

从一个重定向到另一个(无论您以哪种方式进行重定向并不重要)通常被认为是良好的做法,因为它可以让您保持一致(并且可以避免诸如 XHR 请求到特定主机名等问题,当在选择)。

图标无法正常工作可能是由于您的浏览器缓存了 http://www.example.com/favicon .ico 不存在,并且尚未再次检查。 http://example.com/favicon.ico,OTOH,是一个不同的 URI,因此它会有您第一次去那里时检查了它(在您创建图标文件之后)。

The fully qualified domain names are different. So they are different websites.

Usually the two hostnames will point at the same IP address, and the server will be confiured to either serve up the same content for both or redirect from one to the other.

Redirecting from on to the other (and which way round you do it doesn't really matter) is generally considered good practice as it lets you be consistent (and saves you from issues such as XHR requests to a specific hostname breaking when used on the alternative).

The favicon not working is likely caused by your browser having cached that http://www.example.com/favicon.ico didn't exist and it not having yet checked again. http://example.com/favicon.ico, OTOH, is a different URI so it would have checked it the first time you went there (which was after you created the icon file).

尴尬癌患者 2024-09-17 00:30:54

通常,大多数服务器域管理器软件(例如 Cpanel 和 Plex)都配置为为两个域提供相同的站点。 Cpanel 确实有一个 public_htmlwww 分开,但内容相同。

Typically most of the server domain manager software like Cpanel and Plex are configured to serve same site for both domains. Cpanel do have a public_html and www separately, but same content.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文