大网数据广告活动
服务器运维问答

Why website with www works, but without www does not work?

· 52CE 我爱测

I have a website hosted on commercial G-Suite Google Sites where www version of website works properly, however, the non-www version does not work properly: # wget www.fashioncodebeautysalon.com --2018-02-22 21:43:15-- http://www…

问题原文

原帖链接 · user2138912 · CC BY-SA 3.0

I have a website hosted on commercial G-Suite Google Sites where www version of website works properly, however, the non-www version does not work properly:

# wget www.fashioncodebeautysalon.com
--2018-02-22 21:43:15--  http://www.fashioncodebeautysalon.com/
Resolving www.fashioncodebeautysalon.com (www.fashioncodebeautysalon.com)... 172.217.6.51
Connecting to www.fashioncodebeautysalon.com (www.fashioncodebeautysalon.com)|172.217.6.51|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

index.html                                              [ <=>                                                                                                              ]  19.78K  --.-KB/s    in 0.03s   

2018-02-22 21:43:16 (671 KB/s) - ‘index.html’ saved [20257]

# wget fashioncodebeautysalon.com
--2018-02-22 21:43:20--  http://fashioncodebeautysalon.com/
Resolving fashioncodebeautysalon.com (fashioncodebeautysalon.com)... 216.58.195.83
Connecting to fashioncodebeautysalon.com (fashioncodebeautysalon.com)|216.58.195.83|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-02-22 21:43:20 ERROR 404: Not Found.

To get into this state, in the GoDaddy console I simply created DNS A record and copied IP address that I got when accessing www version of website. Is this correct way to create DNS A record, because I don't know if Google guarantees that this particular IP address will remain constant over time? Is there some other specific IP address that I should have put instead?

Since I am getting 404, then I am inclined to think that problem is not with DNS, but rather with Google Sites where their web server expects the "Host:" value in HTTP request header to have the "www" prefix. However, I am unable to add such address mapping in Google Sites console because subdomain field must not be left blank as seen here:

What am I missing here?

已采纳解答

原帖链接 · Nopius · CC BY-SA 3.0

Adding redirect rule from domain.com to www.domain.com in GoDaddy control panel should work. What about your visitors, getting 301 redirect first time they visit your site, it will be cached in their browser. 301 is a permanent redirect code, as opposite to 302 which will not be cached and redirected each time. Which one to use it's up to you.

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

资料来源与适用范围

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

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

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