公開するURLを変更する


通常Word Pressを設置すると、
Word Pressを設置したアドレスとサイト(ブログ)のアドレスは同じになっています。
例えばWord Pressを設置したアドレスが http://sample.com/wordpress/ だった場合、
公開するサイトのアドレスも http://sample.com/wordpress/ になっています。
公開するアドレスは http://sample.com/ にしたい場合が多いと思うので、
その場合は以下の手順で行います。

①管理画面→一般 サイトのアドレス (URL)を変更します。(例)http://sample.com/
※間違ってWord Pressのアドレス(URL)を変更しないように注意。
ここを変更してしまうと管理画面に入れなくなってしまいます。

②設置したWord Pressのフォルダ内のindex.phpを、公開するサイトのディレクトリ内にコピーします。
※.htaccessを利用する場合はこれもコピーします。(パーミッションを書き込み可能にする。)

③コピーした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('./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('./wordpress/wp-blog-header.php');
?>

require(‘./wp-blog-header.php’);の部分を、設置したWord Pressのディレクトリ名に合わせて変更します。
ちなみにディレクトリの階層としては以下のようになります。

  • sample
    • wordpress
      • index.php
      • .htaccess
    • index.php(コピーしたindex.php)
    • .htaccess(コピーした.htaccess)

サーバーによっては階層など変わってくる場合もあるので、要確認が必要です。

記事公開日:
最終更新日:

“公開するURLを変更する” への1件のコメント

  1. […] ※参考ニさせていただいたサイト ▼WP MEMOさんのサイト 公開するURLを変更する […]

wordpress 公開するURLを変更する | ATR トレカテ へ返信する コメントをキャンセル

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)