前提・実現したいこと
htmlで作成されていたサイトをリニューアルを機にwordpressで作り直しました。
https://www.●●●.jp/index.html
にアクセスされたときに
https://www.●●●.jp/
にリダイレクトさせたいと思っています。
発生している問題・エラーメッセージ
知識がないので色んなサイトを参考に.htaccessファイルにリダイレクトの記述をしましたが効きません。
404エラーになります。
同時にwwwありで統一する記述もしましたが、そちらの方は正しく動作しました。
該当のソースコード
別の製作者が.htaccessに色々書いていたのですが一番最後に以下の記述を追記しました。(一応URLは伏せます。)
RewriteEngine on RewriteCond %{HTTP_HOST} ^●●●.com RewriteRule (.*) https://www.●●●.jp/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^.*/index.html RewriteRule ^(.*)index.html$ https://www.●●●.jp/$1 [R=301,L]
何か書き方が間違っていますでしょうか..?
補足情報
念の為、.htaccess全体の記述を記載します。
「# redirect」からが今回追記した分です。別の製作者どういった意図で「# redirect」より上部を記述しているのかもよく分かっていません。。
# 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 # BEGIN Browser Cache <ifModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" ExpiresByType application/x-shockwave-flash "access plus 1 month" ExpiresByType text/css "now plus 1 month" ExpiresByType image/ico "access plus 1 month" ExpiresByType image/x-icon "access plus 1 month" </ifModule> # END Browser Cache <IfModule mod_deflate.c> # Insert filters AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/x-httpd-php AddOutputFilterByType DEFLATE application/x-httpd-fastphp AddOutputFilterByType DEFLATE image/svg+xml # Drop problematic browsers BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </IfModule> # redirect RewriteEngine on RewriteCond %{HTTP_HOST} ^●●●.com RewriteRule (.*) https://www.●●●.jp/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^.*/index.html RewriteRule ^(.*)index.html$ https://www.●●●.jp/$1 [R=301,L]
アドバイスよろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/17 00:37
2019/09/24 02:03 編集