htaccess 301 Redirection Rules

可用的301重定向规则,
不带www的域名重定向到带www
不是https的域名重定向到https

ErrorDocument 404 /404.html
ErrorDocument 403 /403.html

RewriteEngine On


# ensure www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ensure https
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


Nickname*:
E-mail*:
Rate*:
Comments*: