U
U
User0232014-11-20 16:29:37
linux
User023, 2014-11-20 16:29:37

How to set up a redirect from www.examle.ru to examle.ru so that the ssl certificate does not swear?

There is a domain example.ru. Bought an ssl certificate for it. and if you open https://examle.ru, then everything works ok. Problems with www.examle.ru. From www.example.ru there is a redirect to examle.ru. And when you open the https://www.examle.ru
page , the browser swears that the certificate is not valid, then you click continue and the site opens normally without www. And how to make it so that first there is a redirect from www.examle.ru to examle.ru, and only then to https://examle.ru, so that the browser does not swear at the certificate?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Chernov, 2014-11-20
@uinx

answer here:
stackoverflow.com/questions/10294481/how-to-redire...

#
# Redirect all www to non-www
#
server {
    server_name          www.example.com;
    ssl_certificate      ssl/example.com/crt;
    ssl_certificate_key  ssl/example.com/key;
    listen               *:80;
    listen               *:443 ssl spdy;
    listen               [::]:80 ipv6only=on;
    listen               [::]:443 ssl spdy ipv6only=on;

    return 301 https://example.com$request_uri;
}

#
# Redirect all non-encrypted to encrypted
#
server {
    server_name          example.com;
    listen               *:80;
    listen               [::]:80;

    return 301 https://example.com$request_uri;
}

#
# There we go!
#
server {
    server_name          example.com;
    ssl_certificate      ssl/example.com/crt;
    ssl_certificate_key  ssl/example.com/key;
    listen               *:443 ssl spdy;
    listen               [::]:443 ssl spdy;

    # rest goes here...
}

P
Puma Thailand, 2014-11-20
@opium

You have a certificate for only one domain without www.
Usually, a certificate is issued for two domains with and without www, but the request must be sent to the domain with www, and you sent it without www.
reissue the certificate.

V
Vlad Zhivotnev, 2014-11-21
@inkvizitor68sl

_Before_ connecting to a host, the certificate is checked. Prior to the connection, the browser does not know that a redirect will be given there. Only after an encrypted connection is established (well, that is, all that canoe with certificate verification), the browser makes an http request (and receives a 301 in your case).
Accordingly, both names must be in your certificate.
The road to you is in StartSSL or in namecheap for geotrust - they give out to both names (www.domain + domain).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question