blog
.htaccessの設定覚え書き:さくらインターネット
2019.10.02 Akiko Kubo
久しぶりに触ったのでメモ。
仮に下記の前提です。
さくらの初期ドメイン:default.sakura.ne.jp
独自ドメイン:example.co.jp
RewriteEngine On
# さくらの初期ドメイン(特定ディレクトリ)へのアクセスは独自ドメインにリダイレクト
RewriteCond %{HTTP_HOST} ^default\.sakura\.ne\.jp(:80)?$
RewriteRule ^(.*)$ https://www.example.co.jp/$1 [R=301,L]
# httpsに統一
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# wwwありに統一
RewriteCond %{HTTP_HOST} ^(example\.co\.jp)$ [NC]
RewriteRule (.*) https://www.example.co.jp%{REQUEST_URI} [R=301,L]
# index.htmlへのアクセスは/にリダイレクト
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ /$1 [R=301,L]
[prev](https://www.toccaville.com/blog/when-git-command-doesnt-work/)
[一覧に戻る](/blog/)
[next](https://www.toccaville.com/blog/customize-google-calendar-embed-in-your-webpage/)