- ドメインの失効
- サイト名の変更に伴う変更
- サーバー移転時の一時URL
データベースを変更をすれば済むことなのですが、書き込まれている範囲が複数あり、安易に変更すると後悔することになるでしょう・・・。
手作業は難しいので変更する際はツールを使います。
DATABASE SEARCH AND REPLACE SCRIPT IN PHP
変更にはDATABASE SEARCH AND REPLACE SCRIPT IN PHPというツールを利用します。 Database Search and Replace Script in PHP / Interconnect IT – WordPress Consultants, Web Development and Web Designファイルのダウンロード
サイトにアクセスするとページの中央あたりに「DOWNLOAD V3.1.0」というボタンがありますのでそこからダウンロードします。![f:id:photoblg:20161123104721p:plain f:id:photoblg:20161123104721p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/p/photoblg/20161123/20161123104721.png)
ファイルのアップロード
ファイルを解凍後、FTPでサイトURLを変更したいWordpressのインストール先にディレクトリごとアップロードします。![f:id:photoblg:20161123105129p:plain f:id:photoblg:20161123105129p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/p/photoblg/20161123/20161123105129.png)
設定
アップロード完了後、「http://現在のURL/Search-Replace-DB-master/」にアクセスします。![f:id:photoblg:20161123104636p:plain f:id:photoblg:20161123104636p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/p/photoblg/20161123/20161123104636.png)
- 旧ドメイン 変更前のドメイン
- 新ドメイン 変更後のドメイン
- tables 適用するテーブル
![f:id:photoblg:20161123110136p:plain f:id:photoblg:20161123110136p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/p/photoblg/20161123/20161123110136.png)
テスト(dry run)
設定が完了したら、まずはテスト(dry run)を走らせてみます。 actionsセクションに結果が表示され、ドメインの変更箇所があるテーブルに何ヶ所あるか、詳細(view changes)も閲覧することが可能です。![f:id:photoblg:20161123110428p:plain f:id:photoblg:20161123110428p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/p/photoblg/20161123/20161123110428.png)
実行(live run)
テストで特に問題がなければ、変更を実行します。live runをクリックすると確認画面が表示されるので「OK」を選択。![f:id:photoblg:20161123110847p:plain:w300 f:id:photoblg:20161123110847p:plain:w300](https://cdn-ak.f.st-hatena.com/images/fotolife/p/photoblg/20161123/20161123110847.png)
![f:id:photoblg:20161123111159p:plain f:id:photoblg:20161123111159p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/p/photoblg/20161123/20161123111159.png)