I have now tried this Code: if ($http_host != "domain.tld") { rewrite ^(?!/\b(stats|error)\b)/(.*)$ https://domain.tld/$2 redirect; } It only works if you go from http://domain.tld to http://www.domain.tld but it doesn't work if you want http://domain.tld to https://domain.tld so tirelessly looking I found this code that ran on the nginx directives Code: ssl on; error_page 497 https://$host$request_uri; only works with a dedicated IP. by now works very well is this the right path?
I use this redirect: Code: if ($scheme != "https") { rewrite ^ https://www.howtoforge.com$request_uri? permanent; }
A site should never be available on domain.tld and www.domain.tld as thats bad for your search engine rank (duplicate content). So you should decide if your site shall be with or without www and then use my rewrite rule and just replace: https://www.howtoforge.com with your domain (either with www or without).