WordPress の URL 正規化( htaccess で index をルートへリダイレクト)

WordPress で作られたホームページは、
index.php でもアクセスできてしまいます。

両方でアクセス可能
example.com
example.com/index.php

表面上は問題ないですが、SEO対策を考える上で、
URLの分散化(リンク分散)を防止するために、
URLの正規化を行います。

【.htaccess を使った URL 正規化の方法】
※必ず元の .htaccess はバックアップを残してください。

RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*/index.(php|html)
RewriteRule ^(.*)index.(php|html)$ http://example.com/$1 [R=301,L]

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress