RewriteEngine on
- # 强制HTTPS
- RewriteCond %{HTTPS} !=on [OR]
- RewriteCond %{SERVER_PORT} 80
- # 某些页面强制
- RewriteCond %{REQUEST_URI} ^something_secure [OR]
- RewriteCond %{REQUEST_URI} ^something_else_secure
- RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
- # 强制HTTP
- RewriteCond %{HTTPS} =on [OR]
- RewriteCond %{SERVER_PORT} 443
- # 某些页面强制
- RewriteCond %{REQUEST_URI} ^something_public [OR]
- RewriteCond %{REQUEST_URI} ^something_else_public
- RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
复制代码