I need to force, with htaccess, redirect from http to https of a website.

Required when use shared hosting like dreamhost.


For force redirect I use this htaccess

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.us/$1 [R,L]
RewriteRule ^/$ https://domain.us/ [R,L]

redirect domain.us -> https://domain.us


redirect domain.us/sub/ -> https://domain.us/sub/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.