Is there a way to redirect HTTPS requests to HTTP by adding a rule in the domain's vhost file?
Redirect HTTP to HTTPS version for Specified domain in NginxServer_name domain-name.com www.domain-name.com – it specifies the domain names. So, replace it with your website domain name that you want to redirect. Return 301 https://domain-name.com$request_uri – it moves the traffic to the HTTPS version of the site.
When you add an SSL certificate to a domain on your hosting account, the domain will default to being served over HTTPS. If you do not want your site to use HTTPS to serve your site securely, you can change the default from HTTPS to HTTP.
Why is something like that useful? At first look I wasn't sure if it could be done. But it presented an interesting question.
You might try putting a redirect statement in your config file and restarting your server. Two possibilities might happen:
Will add more if I come up with something more concrete.
UPDATE: (couple of hours later) You could try this. You need to put this in your nginx.conf file -
server { listen 443; server_name _ *; rewrite ^(.*) http://$host$1 permanent; }
Sends a permanent redirect to the client. I am assuming you are using port 443 (default) for https.
server { listen 80; server_name _ *; ... }
Add this so that your normal http requests on port 80 are undisturbed.
UPDATE: 18th Dec 2016 - server_name _
should be used instead of server_name _ *
in nginx versions > 0.6.25 (thanks to @Luca Steeb)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With