制作のご相談はこちら
サブディレクトリ(/wp/)のWordPressのURLをドメイン直下に変更する方法

公開日 : 2018年11月19日

サブディレクトリ(/wp/)のWordPressのURLをドメイン直下に変更する方法

サーバー側の仕様上、WordPressの簡単インストールでドメイン直下にインストールしたかったのにサブディレクトリにインストールされてしまうことがあります。

例えばこんな感じです。
【Before】http://design.aekana.com/wp/
【After】http://design.aekana.com/

このように直したい場合は以下の方法で修正することが可能です。

Step.1 WordPressダッシュボード側の修正

メニューの「設定」>「一般」へ移動します。
サイトアドレス (URL)の項目のwp/を消して(Afterの状態)変更を保存します。

Step.2 サーバー側の修正

サブディレクトリ(/wp/直下)にあるindex.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__ ) . '/wp-blog-header.php' );

開くとこのようなソースになっていると思います。
その最終行、/wp-blog-header.php/wp/wp-blog-header.phpに変更します。

このindex.phpと同じ階層にある.htaccessをドメイン直下に移動させます。
これでURLはドメイン直下で表示されます。