E
E
Eugene2016-02-08 10:44:03
Nginx
Eugene, 2016-02-08 10:44:03

How to properly set up a redirect from http && without www to https with www, at the same time, so that the redirects do not affect the /admin folder?

Hello,
Can you please tell me how to correctly set up a redirect from http and without www to https from www, at the same time, so that the redirects do not affect the /admin folder?
Currently configured like this:

server {
  server_name site.com www.site.com;
  rewrite ^(.*) https://$server_name$1 permanent;
  listen ip:80;
}
server {
  server_name site.com;
  rewrite ^(.*) https://www.site.com$1 permanent;
  listen ip:443;
  ssl on;
  ssl_certificate "/var/www/httpd-cert/site/site.com.crtca";
  ssl_certificate_key "/var/www/httpd-cert/site/site.com.key";
}
server {
  server_name www.site.com;
  ...
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2016-02-08
@rusbaron

Try using this instead of ^(.*)

(?s)^((?!admin).)*$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question