Digital site
Digital site

Reputation: 4447

force https to http nginx subdmain

I know this issue has been discussed many times, but I spent last few hours without any success. I have a subdomain that redirect any www to none www and want it as well to redirect any https to http.

here is my nginx vhost:

server {
        listen 80;
        server_name www.stat.domain;
        return 301 http://stat.domain;
}

server {
        listen 80;
        root /home/www/public/;
        index index.php index.html index.htm;
        server_name stat.domain.net;
        location / {
        try_files $uri $uri/ /index.php;
        }
  location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
}

I still don't know why anyone can change the url manually say from http to https on the browser. isn't that supposed to be disallowed especially when a site doesn't have SSL.

any idea how to force https to http?

Upvotes: 0

Views: 197

Answers (1)

Steffen Ullrich
Steffen Ullrich

Reputation: 123521

I still don't know why anyone can change the url manually say from http to https on the browser. isn't that supposed to be disallowed especially when a site doesn't have SSL.

From this sentence I understand that your site does not have any or has no proper SSL. In this case

  • How should the browser know that there is no SSL, before trying to access it? And even then, how should it know that it is an permanent and intended error so that any retries will not work? And if the browser does not know, how should it prevent the user from entering a https-URL?
  • And if you have no https, then how will you redirect from it? A redirection needs a connection, where it can issue the redirect, so no SSL on your site means no https connection and thus no redirect from the https connection.

Upvotes: 2

Related Questions