[WP]WordPress でindex.html をindex.php にリダイレクトする方法
スポンサード
スポンサード
静的ウェブサイトをWordPress でリニューアルするに当たり、今まで使っていたトップページであるindex.html をWordPress 版新サイトのトップページ(index.php)へリダイレクトさせる方法のご紹介です。
.htaccess を編集してindex.html をindex.php へリダイレクト
WordPress の管理画面からパーマリンクを更新すると、サーバー上に以下のような.htaccess ファイルが生成されると思いますが1 2 3 4 5 6 7 8 9 10 11 | # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress |
これをベースに、index.html をindex.php へリダイレクトさせる記述を足します。
1 2 3 4 5 6 7 8 9 10 11 12 | # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.html?$ / [R=301,L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress |
上記ソース5行目
RewriteRule ^index\.html?$ / [R=301,L]
が今回追加した記述です。
スポンサード
コメント