I have done lots try but I’m not getting a solution
I think its not possible. I am not sure though. You may visit sites like upstore, chegg, uptobox and many more. It might help you in this. And if you face any integers issue then https://integralcalculator.info/ guide might help you.
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;
server_name
www.domain.com
domain.com;
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;
server_name
domain.com
;
ssl on;
- now again add the rest of your ssl configuration AGAIN.
If you need more details, please read here:
https://onlyonekenobi.com/nginx-server-redirects/