WEBサイトの移転時など、DNS変更前にPCのhostsファイルを編集して挙動確認をすることもよくあるかと思います。
そこで今回はMac OS Xでhostsファイルを書き換える方法について紹介致します。
Mac OS X のhostsの場所とファイルの書き換え方法
Mac のFinderのメニューバーで「移動」>「フォルダへ移動」を選択し、
/etcを入力します。

/etcフォルダに移動するとhostsファイルがありますので、バックアップを取っておくために、一旦デスクトップなどにコピーします。

/etcフォルダの内のhostsをテキストエディタで開くと、すでに以下のような記述があります。
1 2 3 4 5 6 7 8 9 10 |
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost |
hostsファイルの一番下にIPアドレス ドメイン名の順に追記します。
1 2 3 4 5 6 7 8 9 10 11 12 |
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 192.168.1.1 sample.com |
コメント