.htaccessに書くよくあるやーつ

2019-01-16 /
RewriteEngine on

# wwwありに統一 ↓とどっちか
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$https://www.%{HTTP_HOST}/$1 [R=301,L]

# wwwなしに統一 ↑とどっちか
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

# httpsに統一
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# index.html, index.phpは/にリダイレクト
RewriteCond %{THE_REQUEST} ^.*/index.(html|php)
RewriteRule ^(.*)index.(html|php)$ https://%{HTTP_HOST}/$1 [R=301,L]

# 特定のページをリダイレクト
RewriteEngine On
Redirect 301 /blog/769/ https://lovemac.jp/blog/3967/