Redirect www and non-www http to non-www https on NGINX

16 sec read

How to set up redirect www and non-www http to non-www https

o nginx config file

vim /etc/nginx/sites-enabled/blackonsole.conf

# http
server {
  listen      80;
  server_name blackonsole.org www.blackonsole.org;
  return      301 https://blackonsole.org$request_uri;
}

# https
server {
  listen 443 ssl;
  server_name blackonsole.org;

  # redirect to non-www
  if ($host = 'www.blackonsole.org') {
    rewrite ^/(.*)$ https://blackonsole.org/$1 permanent;
  }
 
  # others
}

o testing config file and restart nginx

nginx -t
nginx -s reload

Hide PHP-FPM Version on NGINX

Check PHP-FPM version on NGINX HTTP response $ curl -I localhost/index.php HTTP/1.1 200 OK Date: Sat, 12 Aug 2017 14:07:54 GMT Content-Type: text/html Connection:...
Sysadmin.ID
16 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *