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!!
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;
}
?>
RewriteBase /
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://test.com/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI}
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.