# Force Redirect http to https

**URL:** <https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839>\
**Category:** RapidWeaver Classic\
**Created:** [June 29, 2018, 6:06am UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839 "2018-06-29T06:06:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 29, 2018, 6:06am UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/1 "2018-06-29T06:06:40Z")

</div>

I had a SSL certificate installed on my website yesterday and want to force all traffic to use https.

The server is a litespeed on a Cloud hosting account. I’ve spent hours on the phone with the hosting company with them finally saying that I would need to do scripting to get this to happen.

The suggest I use a .htaccess file which I have uploaded with the code suggested by “Whynopadlock”

That code is…

RewriteCond %{HTTP\_HOST} [brguitars.com](http://brguitars.com) [NC]  
RewriteCond %{SERVER\_PORT} 80  
RewriteRule ^(.\*)$ [https://www.brguitars.com/$1](https://www.brguitars.com/%241) [R,L]

However as far as I can tell it is not forcing the https protocol. Tested on Safari, Chrome and Microsoft Edge.

Does anyone have a suggestion?

---

<div class="post-metadata">

**Author:** ![NeilUK](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/neiluk/32/23434_2.png) [@NeilUK](https://forums.realmacsoftware.com/u/NeilUK)\
**Post date:** [June 29, 2018, 6:56am UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/2 "2018-06-29T06:56:26Z")

</div>

Try putting `RewriteEngine On` at the very top of your .htaccess file if it’s not there already.

---

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 29, 2018, 7:24am UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/3 "2018-06-29T07:24:38Z")

</div>

I did that and when I try to access the page I get the warning that the page can’t be opened. Possible reason is that a page is trying to redirect that is trying to redirect opening the original page.

---

<div class="post-metadata">

**Author:** ![NeilUK](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/neiluk/32/23434_2.png) [@NeilUK](https://forums.realmacsoftware.com/u/NeilUK)\
**Post date:** [June 29, 2018, 7:27am UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/4 "2018-06-29T07:27:38Z")

</div>

Is there anything other than the redirect in the .htaccess file?

---

<div class="post-metadata">

**Author:** ![instacks](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/instacks/32/23339_2.png) [@instacks](https://forums.realmacsoftware.com/u/instacks)\
**Post date:** [June 29, 2018, 8:54am UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/5 "2018-06-29T08:54:06Z")

</div>

Maybe you should change your redirect directive to:

```
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

```

> **[Redirect to HTTPS](https://instacks.com/blog/?post=redirect-to-https)**
>
> In order to redirect to HTTPS, add an .htaccess file to your website root with a redirect directive.

---

<div class="post-metadata">

**Author:** ![Rovertek](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/rovertek/32/223_2.png) [@Rovertek](https://forums.realmacsoftware.com/u/Rovertek)\
**Post date:** [June 29, 2018, 4:32pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/6 "2018-06-29T16:32:58Z")

</div>

I have this code in my htaccess file and it works for me:

```
# Force your entire website to go through https
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mysite.com/$1 [R=301,L]
```

---

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 29, 2018, 8:58pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/7 "2018-06-29T20:58:11Z")

</div>

I have tried all the suggestions above and in every case it breaks the site.

Same response of page calling to be redirected to the original page.

---

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 29, 2018, 8:59pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/8 "2018-06-29T20:59:26Z")

</div>

And this is the only code in the .htaccess file

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [June 29, 2018, 9:14pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/9 "2018-06-29T21:14:13Z")

</div>

This one should work:

```
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

```

I tested this with your URL `http://www.brguitars.com/` at [https://htaccess.madewithlove.be/](https://htaccess.madewithlove.be/)

---

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 29, 2018, 9:16pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/10 "2018-06-29T21:16:44Z")

</div>

> [@teefers](#):
>
> RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.\*)$ https://%{HTTP\_HOST}%{REQUEST\_URI} [L,R=301]

Just tried it and it breaks the site.

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [June 29, 2018, 9:23pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/11 "2018-06-29T21:23:41Z")

</div>

> [@amcfarlen](#):
>
> breaks the site.

What exactly are you getting when you try the `.htaccess` file?

---

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 29, 2018, 9:25pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/12 "2018-06-29T21:25:07Z")

</div>

That’s an intereresting test site.

I’ve tried the original code and it passes on that site, and doesn’t break the site. Indicating that everything should work. And it doesn’t break anything. But testing on my windows browsers brings up the http page

---

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 29, 2018, 9:27pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/13 "2018-06-29T21:27:06Z")

</div>

> [@teefers](#):
>
> RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.\*)$ https://%{HTTP\_HOST}%{REQUEST\_URI} [L,R=301]

I have that code up there right now and it says that there are too many redirections. I’ll leave it in place for a bit if you’d like to have a look

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [June 29, 2018, 9:38pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/14 "2018-06-29T21:38:07Z")

</div>

I see the message, Not sure why it is happening.  
Who is your hosting company?  
Do you have anything else in the htaccess file?  
Do you have any other redirects (maybe a cPanel entry)?

---

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 29, 2018, 9:40pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/15 "2018-06-29T21:40:45Z")

</div>

The company is Netregistry in Australia. It’s a Cloud hosting package, not a cPanel one. No other redirects.

It’s the only thing in the .htaccess file.

I’ve swapped the code back to the orignial one at the top of the page as at least its not taking the site down.

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [June 29, 2018, 10:03pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/16 "2018-06-29T22:03:48Z")

</div>

I looked at their [support area](https://support.netregistry.com.au/articles/nr/URL-redirection/?q=ssl+redirect&fs=Search&pn=1#cloud), and the code should work. I did notice your home page is getting errors on the browser console. Now that shouldn’t have any effect on the redirects.

ERR\_TOO\_MANY\_REDIRECTS is likely due to an infinite redirect loop. Now since you have no other redirects, and the one I gave you works. I would go to your hosting support and either chat with them or cut a ticket.

---

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 29, 2018, 10:29pm UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/17 "2018-06-29T22:29:43Z")

</div>

Thanks for the help. I’ll see what I can do with respect to contacting them and sorting it out. I was on the phone with them for hours yesterday for them to finally say that redirects were a scripting job and they weren’t responsible for that.

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [June 30, 2018, 12:25am UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/18 "2018-06-30T00:25:34Z")

</div>

I can tell you for sure the script I listed above works 100%. It’s listed in multiple web hosting knowledge bases. It’s completely generic, notice no mention of your URL.

---

<div class="post-metadata">

**Author:** ![mdlong](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@mdlong](https://forums.realmacsoftware.com/u/mdlong)\
**Post date:** [June 30, 2018, 3:57am UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/19 "2018-06-30T03:57:29Z")

</div>

It may well be a problem with your hosting company, in spite of what their support representative initially told you. Yesterday I noticed that my own site suddenly stopped working and was giving me a “Too many redirects error”, even though it had been working flawlessly for a few weeks (I’ve just made the move to SSL).

I contacted the hosting company and they initially told me that they fixed the problem. But then it only lasted 10 minutes before it happened again. This cycle kept being repeated for a couple of hours, with repeated assurances that they’d fixed the issue, until finally it was solved on their end. They never did tell me what the issue was, and why my site started spontaneously throwing up such errors.

---

<div class="post-metadata">

**Author:** ![amcfarlen](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@amcfarlen](https://forums.realmacsoftware.com/u/amcfarlen)\
**Post date:** [June 30, 2018, 4:12am UTC](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839/20 "2018-06-30T04:12:15Z")

</div>

I’ve had the help of a fellow that does this stuff for a living, and every bit of code we’ve tried has either broken the site, or doesn’t do the job. He’s going to be calling Netregistry to find out what is happening on their end, and if they have a prefered method and syntax of redirect, as all the usual methods don’t work.

[Next page](https://forums.realmacsoftware.com/t/force-redirect-http-to-https/20839.md?page=2)
