E
E
entermix2016-08-11 15:43:58
Nginx
entermix, 2016-08-11 15:43:58

Why does the redirect from WWW not work?

There is a bunch of nginx + apache:
The final address should look like this: https://example.ru (i.e. only https, without www)
I do this:
pastebin.com/4rea3sZ6
https always works, but www remains, i.e. works both https://example.ru and https://www.example.ru, why is that?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Shatokhin, 2016-08-11
@entermix

so you don’t have a redirect from https://www.example.com
Add options to the server with the redirect to access via https.
And you can immediately change return 301 $scheme://example.ru$request_uri; on return 301 https://example.ru$request_uri;

I
Igor Vasiliev, 2016-08-11
@Isolution666

))) I don’t see a problem with this at all, I created a .htaccess
file in the root of the site - once
I opened the file, I wrote:

AddDefaultCharset UTF-8

RewriteEngine On
RewriteCond %{HTTP:HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

- two
And saved, no redirects and extra files, I ate a dog on these SSL certificates)))
Everything works fine for me!
PS note, as you can see in the example above, I did not write www , it is not needed there, when typing a link from www it returns
https://example.com

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question