Title: Http redirect to https with www use htaccess
Last modified: March 25, 2020

---

# Http redirect to https with www use htaccess

 *  Resolved [Loc_rabbirt](https://wordpress.org/support/users/loc_rabbirt/)
 * (@loc_rabbirt)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/http-redirect-to-https-with-www-use-htaccess/)
 * I tried redirect it with this code in my htaccess:
 *     ```
       RewriteEngine On
       RewriteBase /
       RewriteCond %{HTTP_HOST} !^www\. [NC]
       RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
       ```
   
 * But when I tried load my page:
 * [http://goodlayers.tienloc.net/traveltour/tour/tour-custom-template/](http://goodlayers.tienloc.net/traveltour/tour/tour-custom-template/)
 * goodlayers.tienloc.net/traveltour/tour/tour-custom-template/
 * Its not redirect/force to https, it just loaded to http with www. Please don’t
   recommended me to use plugin, I don’t want use plugin so I tried with htaccess.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhttp-redirect-to-https-with-www-use-htaccess%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  anonymized-17844177
 * (@anonymized-17844177)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/http-redirect-to-https-with-www-use-htaccess/#post-12584640)
 * **loc_rabbirt**, hi.
 * **Method #1:**
 *     ```
       RewriteEngine On
       RewriteCond %{SERVER_PORT} !^443$
       RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
       ```
   
 * http:// >> https:// (+ [http://www](http://www) >> [https://](https://wordpress.org/support/topic/http-redirect-to-https-with-www-use-htaccess/?output_format=md))
 * **Method #2:**
 *     ```
       RewriteEngine On
       RewriteCond %{HTTPS} =off 
       RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]
       ```
   
 * **Method #3:**
 *     ```
       RewriteEngine On
       RewriteCond %{HTTPS} off
       RewriteCond %{HTTP:X-Forwarded-Proto} !https
       RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
       ```
   
 * **Method #4:**
 *     ```
       RewriteEngine On 
       RewriteCond %{ENV:HTTPS} !on 
       RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
       ```
   
 * Hope it helps 🙂
 *  Thread Starter [Loc_rabbirt](https://wordpress.org/support/users/loc_rabbirt/)
 * (@loc_rabbirt)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/http-redirect-to-https-with-www-use-htaccess/#post-12585774)
 * Hi,
 * If I understand it well, none of methods work with: http > https + www? Could
   you advice some way to force http > https + www?
 *  Thread Starter [Loc_rabbirt](https://wordpress.org/support/users/loc_rabbirt/)
 * (@loc_rabbirt)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/http-redirect-to-https-with-www-use-htaccess/#post-12599813)
 * Already resolve with clarify details in [StackOverflow](https://stackoverflow.com/questions/60846460/redirect-http-non-www-to-https-with-www-for-subfolder)
 * The code below work for me:
 *     ```
       RewriteCond %{HTTPS} off [OR]
       RewriteCond %{HTTP_HOST} !^www\.
       RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+?)\.?$ [NC]
       RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Http redirect to https with www use htaccess’ is closed to new replies.

## Tags

 * [htaccess](https://wordpress.org/support/topic-tag/htaccess/)
 * [HTTP](https://wordpress.org/support/topic-tag/http/)
 * [HTTPS](https://wordpress.org/support/topic-tag/https/)
 * [redirect](https://wordpress.org/support/topic-tag/redirect/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Loc_rabbirt](https://wordpress.org/support/users/loc_rabbirt/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/http-redirect-to-https-with-www-use-htaccess/#post-12599813)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
