Reputation: 55
I've used different codes provided here on other questions' solutions and on the internet. I'm really not savvy with htaccess
. Bought and confirmed working SSL Certificate, but I'm new to applying these redirects.
Goal: I need to rewrite http to https on the following directories.
I'm on shared hosting via Dreamhost. I have a dedicated IP, if that helps.
Initial code I was using recommended to me by a Dreamhost representative:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} wp-login
RewriteRule ^(.*)$ https://mydomain.com/wp-login/$1 [R,L]
Upvotes: 4
Views: 5458
Reputation: 143946
Try these rules in the htaccess file in your document root.
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^(/wp-login|/products-page/checkout|/products-page/your-account)
RewriteRule ^(.*)$ https://mydomain.com/$1 [R,L]
The first condition checks if the request isn't HTTPS, the second checks if the request starts with either /wp-login
, /products-page/checkout
, or /products-page/your-account
, and if both apply, then the rewrite simply takes the entire URI and redirects to https://.
Upvotes: 4