hostファイル

 2025年12月5日に、ネームサーバーを変更し、ドメイン名は変更せずに、サーバーを引っ越ししたのですが、メインに使っているWindowsが、旧サーバーにアクセスし、新サーバーにアクセスしません。キャッシュ履歴をしたり、スーパーリロードを行ったのですが、アクセスしません。2,3日程で、ユーザーは、新サーバーに切り替わっていきました。それで、googleで、AIモードで、出てきたのは、以下です。

 Windows の場合: 管理者としてメモ帳を開き、C:\Windows\System32\drivers\etc\hosts ファイルを開きます。ファイルの最後に 127.0.0.1 [旧サイトのURL]  (例: 127.0.0.1 old.mike3.net)を追加して保存します。

 それで、hostファイルを開いてみたら、次のように出てきました。

# Copyright (c) 1993-2009 Microsoft Corp.
#
# his is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
#
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
  旧サーバーのIPアドレス ○○○○.net
  旧サーバーのIPアドレス www.○○○○.net

 最後の2行目から、自分でこのファイルに書き込みを行っていたことを忘れていました。それで、新IPアドレスに書き換えて、再度アクセスしたら、新サイトが表示されました。
 なお、現在は、新サーバーのIPアドレスとURLは、削除してあります。

 後で調べたら、さくら internetのページに、「動作確認のためにhostsファイルを利用したい」というページがありました。⇒ 関連記事

 hostファイルmacでは、「 /private/etc/ または /etc/ 」にあるようです。