WordPressでindex.phpを/ルートにリダイレクトする方法

既存のサイトをWordPressに置き換えたあと、index.htmlの件以外にも問題が発生しました。

index.phpでもアクセスできてしまう

広告

WordPressでは、全てのURLは実際には存在しないファイルを、index.phpで受けてmod_rewriteで生成して出力しています。
つまり、唯一の実在ファイルがindex.phpのため、ここにアクセスされるとそのまま表示されてしまうのです。

http://blog.dacelo.info/index.php
http://blog.dacelo.info/
(どちらも表示されてしまう!)

これは、「URLの分散化」ということで、SEO的に損をしてしまいます。

解決方法は2つあります

.htaccessでリダイレクト処理

.htaccess に以下のリダイレクトを追加

Redirect permanent /index.html http://blog.dacelo.info/

index.phpにアクセスされると、自動的に / にリダイレクトするので、これでもOKです。

Redirect permanent /index.html http://blog.dacelo.info/index.php

プラグインRedirectionを使う

WordPressのリダイレクトを管理するプラグイン、Redirectionを使います。
WordPress › Redirection « WordPress Plugins
リダイレクトのマッチ回数がカウントされるので便利ではありますが、htaccessで解決するならそれがベターでしょう。

About: dacelo


3 thoughts on “WordPressでindex.phpを/ルートにリダイレクトする方法”

  1. stx21 wous Vag Binquic noclegi pracownicze niedaleko augustowa noclegi pracownicze niedaleko suwalk noclegi w augustowie i okolicach noclegi augustow blisko jeziora noclegi augustow agroturystyka

Leave a Reply

Your email address will not be published. Required fields are marked *