Skip to main content

.htaccess for HTTP redirect to HTTPS

# .htaccess in your webroot
RewriteEngine On

# If not already HTTPS…
RewriteCond %{HTTPS} !=on

# …and not marked HTTPS by a proxy/load balancer
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP:Forwarded} !proto=https

# Redirect to same host+path on HTTPS
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]