Redirect from httpS to http

Tell me the redirect for the redirection of all the pages of the site, when changing the protocol with the preservation of the structure. te - https: //www.site.ru/catalog/ -->301--> http: //www.site.ru/catalog/

I tried both with the indication of the port, and the conditions from the opposite !=

Thank you all!!

 0
Author: okseo, 2015-05-21

4 answers

Try this way:

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

If it doesn't work, try placing them between <IfModule mod_rewrite.c> and the one above </IfModule>

If this does not work, then replace the drain RewriteCond %{HTTPS} on with this line RewriteCond %{SERVER_PORT} ^443$

Well, or try the php code

<?php 
if  ( $_SERVER['HTTPS'] ) 
        { 
                $host = $_SERVER['HTTP_HOST']; 
                $request_uri = $_SERVER['REQUEST_URI']; 
                $good_url = "http://" . $host . $request_uri; 

                header( "HTTP/1.1 301 Moved Permanently" ); 
                header( "Location: $good_url" ); 
                exit; 
        } 
?> 
 1
Author: Андрей, 2015-05-22 04:31:46
RewriteBase /
RewriteCond %{SERVER_PORT} ^443$ [OR] 
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://test.com/$1 [R=301,L]
 0
Author: , 2015-05-21 23:47:01
RewriteCond %{HTTPS} on
RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI}
 0
Author: Узбек Баха, 2015-05-22 04:16:22

In Nginx, you can use the return url state code directive. To translate the schema with the url saved:

server {
  listen 443 ssl;

  location / {
    return http://www.domain.tld$request_uri;
  }
}

Variable $request_uri request path to your resource The return directive can be set at the context level of server, location, if.

 0
Author: Alex, 2016-09-23 07:49:32