http://sample.jp/testのサイトをhttp://sample.jpで見れるようにする。
条件
- 同一ドメイン内の引っ越し
- ただ引っ越すだけなのでデータベースもそのまま同じものをつかう
ディレクトリ構成
sample.jp/public_html/test/(wordpress関連ファイル群)
もくじ
サイトアドレス(URL)を変更する
wordpress管理画面から設定>一般
サイトアドレスの方を
http://sample.jp
に変更する。
ポイント
→wordpressのファイルが実際にどのディレクトリにあるかを指し示す。
→実際にアクセスするためのURL
index.phpを複製・編集
index.phpの複製・ルートへの移動
sample.jp/public_html/testの中にあるindex.phpをコピーし、ドメイン直下に複製します。
(sample.jp/public_html/testのpublic_htmlと同じ場所。)
index.php内のコードを編集
ドメイン直下に複製したindex.phpを編集します。
編集箇所は15行目。
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/test/wp-blog-header.php' );15行目の
require( dirname( FILE ) . ‘/wp-blog-header.php’ );
を
require( dirname( FILE ) . ‘/test/wp-blog-header.php’ );
に書き換える。
ドメインをたたいてみる
http://sample.jpで表示されればOK。
パーマリンクの更新
http://sample.jpでTOPが表示されても下層が表示できなかったりする。
その場合、
WordaPress管理画面>設定>パーマリンク設定
でそのまま画面一番下の変更を保存ボタンを押します。
引っ越し後に忘れずにやること
- SSL化
- .htaccessにて301リダイレクトをかける