Join the community today
Register Now

Nginx How to redirect www.domain.com to www.domain.com/forums ?

Discussion in 'Nginx and PHP-FPM news & discussions' started by modder, May 5, 2020.

  1. modder

    modder Member

    94
    15
    8
    Dec 6, 2019
    Ratings:
    +23
    Local Time:
    11:22 AM
    I'm using CENTOS 7 and latest CENTMINMOD now.

     
  2. modder

    modder Member

    94
    15
    8
    Dec 6, 2019
    Ratings:
    +23
    Local Time:
    11:22 AM
    There are so much to read!

    Code (Text):
    server {
          listen   80;
          server_name myplace.com www.myplace.com;
          return 301 https://$server_name$request_uri;
    }
    
    server {
      listen 443 ssl http2 reuseport;
      server_name myplace.com www.myplace.com;
      rewrite ^/$ /forums redirect;


    I added the last line...

    rewrite ^/$ /forums redirect;

    And it works. Is the the best way to do it?

    Thanks.
     
  3. JoeDer

    JoeDer Member

    82
    19
    8
    Feb 22, 2015
    Ratings:
    +48
    Local Time:
    5:22 AM
    Nginx 1.21.x
    MariaDB 10.3.x