【WP移転】hostsファイル編集で表示確認する方法
WPの移転で、移転先でも同じドメインを利用する場合、新環境では表示確認することができない(同じドメインだと旧サイトを表示してしまう)ため、hostsファイルを編集してローカルでのみ表示させる。
Win
- メモ帳を管理者モードで開く
- メモ帳からhostsファイル(C:\Windows\System32\drivers\etc\hosts)を開く
Mac
- Finderのメニューバー→移動→フォルダへ移動をクリック。/private/etcと入力し、hostsファイルのあるフォルダを開く。
- hostsファイルをデスクトップなどにコピーし、miなどのテキストエディタで開く。
共通
- Finderのメニューバー→移動→フォルダへ移動をクリック。/private/etcと入力し、hostsファイルのあるフォルダを開く。
- hostsファイルをデスクトップなどにコピーし、miなどのテキストエディタで開く。
- hostsファイル内を編集(行を追加、もしくは削除)
111.22.XXX.YY部分には移行したいサーバーのグローバルIPアドレスを入力。タブキーでスペースを空け(スペースキーは×)hogehoge.com部分には、移行予定のドメイン(http://やhttps:// は不要)やHOST名を入力。
- 編集後上書き保存
- 追加した行頭に#(コメントアウト)をつけることで必要に応じ切り替えができる
設定例(ロリポップ)
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This 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
163.44.185.222 hogehoge.com
WPの設定
- 設定からサイトアドレスを本番ドメインに変更

