Title: force from https://www to https
Last modified: September 1, 2016

---

# force from https://www to https

 *  Resolved [johnc1979](https://wordpress.org/support/users/johnc1979/)
 * (@johnc1979)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/force-from-httpswww-to-https/)
 * Hi everyone,
 * I hope someone can help me and I’m not in the wrong place.
 * I recently moved hosts and my old host had the default domian as [https://www](https://www).
   Since moving to Godaddy it’s been switched to https. I have redirects in the .
   htaccess file to point to the non www version, but whenever someone visits the
   [https://www](https://www) version the site is broken and doesn’t load the css.
   The weird thing is if you refresh the page it loads correctly.
 * I’ve switched the preferred domain in Webmaster tools to the https version, but
   the [https:///www](https://wordpress.org/support/topic/force-from-httpswww-to-https/?output_format=md).
   is still causing problems.
 * At the top of the .htaccess I have this
 *     ```
       RewriteEngine On
   
       # match any URL with www and rewrite it to https without the www
       RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
       RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301]
   
       # match urls that are non https (without the www)
       RewriteCond %{HTTPS} off
       RewriteCond %{HTTP_HOST} !^(www\.)(.*) [NC]
       RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
       ```
   
 * What am I doing wrong? It works, but only on a refresh. I don’t want to drive
   customers away with an ugly broken site.

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

 *  [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/force-from-httpswww-to-https/#post-7480512)
 * Try replacing your rewrite code with this.
 *     ```
       # Redirect Non-WWW to WWW
       RewriteCond %{HTTP_HOST} !^www\.
       RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
   
       # Redirect HTTP to HTTPS
       RewriteEngine On
       RewriteCond %{HTTPS} !=on
       RewriteRule .* https://www.yoursite.com%{REQUEST_URI} [R,L]
       ```
   
 *  Thread Starter [johnc1979](https://wordpress.org/support/users/johnc1979/)
 * (@johnc1979)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/force-from-httpswww-to-https/#post-7480553)
 * Thanks for the snippet Davood Dehnavi, but it didn’t work. 🙁
 * It looks like the snippet you gave me is trying to direct to [https://www.mysite.com](https://www.mysite.com)
   where I want to direct all to [https://mysite.com](https://mysite.com)
 * This is what I want
 * www >>[https://mysite.com](https://mysite.com)
    [http://www](http://www) >>[https://mysite.com](https://mysite.com)
   http:// >>[https://mysite.com](https://mysite.com) [https://www](https://www)
   >>[https://mysite.com](https://mysite.com)
 * I’ve currently got everything but [https://www](https://www) >>[https://mysite.com](https://mysite.com)
   working
 * The original snippet I used above works, but never on the first load for the 
   [https://www](https://www). It only works when the page is refreshed
 *  [cedcommerce](https://wordpress.org/support/users/cedcommerce/)
 * (@cedcommerce)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/force-from-httpswww-to-https/#post-7480604)
 * Hello johnc1979,
 * Please try the following code in your .htaccess file and remove your code:
 *     ```
       RewriteEngine On
   
       # Check that you're on port 443 and the hostname starts with www
       RewriteCond %{SERVER_PORT} ^443
       RewriteCond %{HTTP_HOST} ^www\.
   
       # Redirect to domain without the www
       RewriteRule (.*) https://yoursite.com$1 [L,R,QSA]
       ```
   
 *  [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/force-from-httpswww-to-https/#post-7480605)
 * [@johnc1979](https://wordpress.org/support/users/johnc1979/), I misunderstood
   what you were trying to do… You can use the code that was provided by [@cedcommerce](https://wordpress.org/support/users/cedcommerce/)
   or you can change the code I provided to this
 *     ```
       # Force url without WWW
       RewriteBase /
       RewriteCond %{HTTP_HOST} !^yoursite.com$ [NC]
       RewriteRule ^(.*)$ http://yoursite.com/$1 [L,R=301]
   
       # Force https
       RewriteCond %{HTTP_HOST} ^yoursite\.com [NC]
       RewriteCond %{SERVER_PORT} 80
       RewriteRule ^(.*)$ https://yoursite.com/$1 [R,L]
       ```
   
 *  Thread Starter [johnc1979](https://wordpress.org/support/users/johnc1979/)
 * (@johnc1979)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/force-from-httpswww-to-https/#post-7480610)
 * It all seems to be good now. I just tried loading it again using the top code
   and it redirected the first time perfectly. Not sure why it wasn’t working that
   way to begin with, but it seems ok now.

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

The topic ‘force from https://www to https’ is closed to new replies.

## Tags

 * [htaccess](https://wordpress.org/support/topic-tag/htaccess/)
 * [HTTPS](https://wordpress.org/support/topic-tag/https/)
 * [non www](https://wordpress.org/support/topic-tag/non-www/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [johnc1979](https://wordpress.org/support/users/johnc1979/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/force-from-httpswww-to-https/#post-7480610)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
