Mario Parra
Mario Parra

Reputation: 1554

Temporarily redirect https domain to http

How can I configure my NGINX conf file to temporarily redirect an https domain to the http version?

I've found ways to redirect http to https, which is more common, but not the other way around. The reason I need to do this is because I'm in the process of setting up an SSL certificate for a website and somehow, some https URLs are being indexed, on which some assets don't load without the certificate. Thank you in advance!

Upvotes: 1

Views: 134

Answers (1)

iquito
iquito

Reputation: 2555

The problem with redirecting https to http is that you still need a certificate for https - so if you want to redirect because you do not have the certificate yet, this will probably not solve anything, because the secure https connection happens before the redirect.

Otherwise redirecting from https to http works the same as the other way round - it could look something like this: (server block in your http config)

server {
  listen  443 ssl;

  server_name yourdomain.com;

  ssl_certificate      /certificate.pem;
  ssl_certificate_key  /certificate.key;

  return 302 http://$host$request_uri;
}

You just need to adjust the domain name and the certificate paths/filenames.

Upvotes: 1

Related Questions