2

I am trying to force my site to redirect from https to http, most of the tutorials out there do the opposite (force http to https), the few one's that I have come across haven't worked for me so far.

This is what my .htaccess file looks like right now

    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress
TobiSkillZ
  • 85
  • 1
  • 5
  • Any of the answers below will work. Just replace one of them with your own and refresh your cache. – Joe Jan 26 '17 at 12:48

3 Answers3

1

Use this to force HTTPs:

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Make sure you clear your cache before testing this.

Joe
  • 4,877
  • 5
  • 30
  • 51
1

Use this to force to http:

RewriteEngine on
RewriteCond %{HTTPS} on 
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
Croises
  • 18,570
  • 4
  • 30
  • 47
1

You do exactly the opposite, namely if it comes from HTTP

RewriteCond %{SERVER_PORT} 80

redirect to HTTPS

RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Remove these two lines and replace with the following.


First, you should not check for the port, but for %{HTTPS}, which is more reliable, e.g.

RewriteCond %{HTTPS} on

next redirect to HTTP (note the missing s)

RewriteRule ^(.*)$ http://www.example.com/$1 [R,L]

When everything works as it should, you may replace R with R=301. Never test with R=301.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198