J
J
Jora Fribsd2014-09-14 12:52:02
Nginx
Jora Fribsd, 2014-09-14 12:52:02

Reverse redirect from HTTPS to HTTP?

I use: Nginx (frontend) + (communicate via http) apache (backend) + php
It was necessary to enable HTTPS. Connected, done, then redirect https to http:
if ( $scheme = "http" ) {
rewrite ^/(.*)$ https://$host/$1 permanent;
}
Only I regretted this (due to ignorance of SEO), I had to make two HTTPS and HTTP connections, it turned out that google can only index HTTP and ignore HTTPS, but instead I made it index HTTPS, but in fact I don’t need it ( you only need to implement https for those who need it), ideally, you need people to log in via HTTP (and the PS indexed HTTP), which means you need to remove the redirect back.
What I did: I
commented out #if ( $scheme = "http" ) {
RESULT: if you clear the browser cache, you can go to http without problems, but if you go through https at least once, then the browser no longer wants to communicate through http and always throws at https, there are no other redirects.
Say it's a browser specification?
And how to redirect from HTTPS to HTTP, since PS indexed HTTPS, or your solution to this problem?
I tried:
1. Redirect if ( $scheme = "https" ) - reverse, got - "circular redirect"
2. htaccess - did, doesn't channel
3. Did redirect via PHP - got - "circular redirect"
UPD
//
Necessary just make HTTPS to HTTP but I don't know how to do it through

if ( $scheme = "https" ) {
    rewrite ^/(.*)$   http://$host/$1 permanent;
}

It turns out a cyclic redirect

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Maksim Zverev, 2014-09-14
@m1skam

Who told you that Google can only index http?????
Here are 2 requests for verification:
Request 1
Request 2

P
Puma Thailand, 2014-09-14
@opium

no, this is not a browser specification, everything goes to http and https and no redirects appear.

J
Jora Fribsd, 2014-09-14
@evoltrue

I can’t find out where I have this redirect
Here are the configs

server {
    listen  *.*.*.*:80;
    listen  *.*.*.*:443 ssl;
    server_name site.net www.site.net;
    error_log  /var/log/httpd/domains/site.net.error.log error;
  
    ssl         on;
    ssl_certificate     /home/admin/web/site.net/cert/site.chained.crt;
    ssl_certificate_key /home/admin/web/site.net/cert/site.key;
    
    add_header Strict-Transport-Security 'max-age=604800';
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    #if ( $scheme = "https" ) {
    #    rewrite ^/(.*)$   http://$host/$1 permanent;
    #}

    location / {
        proxy_pass      http://*.*.*.*:8080;
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|css|zip|tgz|gz|rar|bz2|exe|pdf|doc|xls|ppt|txt|odt|ods|odp|odf|tar|bmp|rtf|js|mp3|avi|mpeg|flv|html|htm)$ {
            root           /home/admin/web/site.net/public_html;
            access_log     /var/log/httpd/domains/site.net.log combined;
            access_log     /var/log/httpd/domains/site.net.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

    location /error/ {
        alias   /home/admin/web/site.net/document_errors/;
    }

    location @fallback {
        proxy_pass      http://*.*.*.*:8080;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include /home/admin/conf/web/nginx.site.net.conf*;
}

// htaccess
AddDefaultCharset utf-8

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTP_HOST} ^www.site.net
    RewriteRule (.*) http://site.net/$1 [R=301,L]

    RewriteCond $1 !^(index\.php)

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteRule ^(.*)$ index.php?/$1 [L]

</IfModule>

You just need to do HTTPS to HTTP but I don’t know how to do it through
if ( $scheme = "https" ) {
    rewrite ^/(.*)$   http://$host/$1 permanent;
}

It turns out a cyclic redirect

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question