.htaccess rewrite ssl https redirect URL

I used the different codes presented here on other issues and on the Internet. I do not understand htaccess . I bought and confirmed a valid SSL certificate, but I'm new to the use of these redirects.

Purpose: I need to rewrite http to https in the following directories.

I am on shared hosting through Dreamhost. I have a dedicated IP if that helps.

The source code that I used was the recommended representative of Dreamhost:

 RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} wp-login RewriteRule ^(.*)$ https://mydomain.com/wp-login/$1 [R,L] 
+4
source share
1 answer

Try these rules in the htaccess file in the root directory of the document.

 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 is not HTTPS, the second checks whether the request starts with /wp-login , /products-page/checkout or /products-page/your-account , and if both apply, then the rewrite just takes the whole URI and redirects to https: //.

+4
source

All Articles