Remove WWW prefix from your website

前端 未结 9 610
情歌与酒
情歌与酒 2020-12-28 19:24

How does Stack Overflow (and other web sites) remove the \'www\' prefix when it\'s entered as part of a URL?

Is it a redirect, a rewrite or something else entirely?<

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-28 20:16

    Firing up Fiddler, we can see that the server responses with a "301 Moved Permanently" status and refers it to http://stackoverflow.com . Since StackOverflow is hosted on Windows 2k8 IIS7 they set up this redirect straight away in IIS7.

    FYI:

    a list of HTTP statuses

    If you are a .NET developer you might know "Respose.Redirect" , this creates a 302 Object Moved status. Search engines like 301 status codes in this case better, because they know they should not come back to www.stackoverflow.com in the future.

提交回复
热议问题