目的
- さくらレンタルサーバで、初期ドメインから独自ドメインへのリダイレクトさせたい。
前提
- さくらレンタルサーバ(スタンダード)で運用中。
- 初期ドメイン: hoge.sakura.ne.jp
- 独自ドメイン: hoge.co.jp
- SSL: あり
- .htaccess格納ディレクトリ: /home/hoge/www
- WordPress: あり
- WordPress格納ディレクトリ: /home/hogehoge/www/hogehoge
.htaccess#1の場合
RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?[^.]+\.sakura\.ne\.jp$ [NC] RewriteRule .* https://hoge.co.jp%{REQUEST_URI} [R=301,L]
エラーログ
[Tue Oct 17 11:16:00.094043 2023] [core:alert] [pid 38294] [client 100.64.0.64:54924] /home/hoge/www/.htaccess: Invalid command 'XPagespeed', perhaps misspelled or defined by a module not included in the server configuration, referer: https://hoge.co.jp/ [Tue Oct 17 11:16:00.236174 2023] [core:alert] [pid 32466] [client 100.64.0.64:54925] /home/hoge/www/.htaccess: Invalid command 'XPagespeed', perhaps misspelled or defined by a module not included in the server configuration, referer: https://hoge.co.jp/ [Tue Oct 17 11:16:02.771029 2023] [core:alert] [pid 32537] [client 100.64.0.64:54927] /home/hoge/www/.htaccess: Invalid command 'XPagespeed', perhaps misspelled or defined by a module not included in the server configuration
.htaccess#2の場合
Redirect permanent / "https://hoge.co.jp/"
.htaccess#3の場合
RewriteEngine on RewriteBase / RewriteRule hoge.sakura.ne.jp/ "https://hoge.co.jp" [R=301,L]
結果
https://hoge.sakura.ne.jp/
https://hoge.co.jp
上記をブラウザで表示すると、
どの.htaccess表記でも、internal server error になってしまいます(格納ディレクトリは同じです)。
さくらサポートでは、個別のリダイレクト設定詳細まではサポートいただけず、
途方に暮れております。
ちなみに、.htaccessを配置していない状態ですと、
https://hoge.sakura.ne.jp/ は forbidden となっています。
以上、ご教示いただきたく、どうぞよろしくお願いいたします。
自己解決
.htaccess#1の場合のみですが、以下の箇所をコメントアウトして解決いたしました。
### BEGIN XPageSpeed - Do not edit the contents of this block! ### XPagespeed on <IfFile /var/xpagespeed/xpagespeed_ctl> XPagespeed off </IfFile> ### END XPageSpeed - Do not edit the contents of this block! ###
また、上記コメントアウトしても、.htaccess#2については、
ブラウザ上では、リダイレクトが繰り返し行われた旨、表示されまさせんでした。
エラーログ
[Tue Oct 17 11:16:24.095943 2023] [autoindex:error] [pid 38287] [client 153.220.76.151:0] AH01276: Cannot serve directory /home/hoge/www/: No matching DirectoryIndex (index.html,index.htm,index.shtml,index.shtm,index.cgi,index.php,index.hdml) found, and server-generated directory index forbidden by Options directive
記述が間違っているのかもしれません。
いったん、こちらで様子を見たいと思います。
ありがとうございました。
回答1件
あなたの回答
tips
プレビュー