I Want To Redirect WWW to Non WWW With HTTPS

I have done lots try but I’m not getting a solution

I think its not possible…

You have to do this with in 3 parts.
You can put the rules inside your ssl configuration file

1. The first block will redirect all http traffic to non-www https.

server {
    listen 80;
    return 301 https://domain.com$request_uri;

2. The second block will redirect https-www requests to non-www https.

server {
    listen 443 ssl;
    server_name domain.com;
    return 301 $scheme://domain.com$request_uri;
ssl on;

after add the rest of your ssl rules in order to work, otherwise you will get an error.

3. The third block will be the final output (https://domain.com) which will handle everything else. Here you can add whatever you might need in your ssl configuration.

server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;


	ssl on;
  • now again add the rest of your ssl configuration AGAIN.

If you need more details, please read here: