Nginx Redirect

Discussion in 'Nginx' started by edmwsg, Apr 25, 2013.

  1. #1
    Hi,

    I want to redirect my main site domain.com to sub.domain.com/portal/ but with the url on the address bar remain as domain.com instead of sub.domain/portal/

    Is it possible? Kindly show me the way to do it. Thanks.
     
    edmwsg, Apr 25, 2013 IP
  2. kuszeras

    kuszeras Active Member

    Messages:
    326
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #2
    Use rewrite and not redirect. http://wiki.nginx.org/HttpRewriteModule
     
    kuszeras, May 11, 2013 IP
  3. x-man

    x-man Active Member

    Messages:
    212
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    You can do it if set root folder of domain.com to root folder of sub.domain/portal/ in nginx.conf
     
    x-man, Aug 26, 2013 IP
  4. tobalsan

    tobalsan Well-Known Member

    Messages:
    63
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Edit your vhost, and this at the very beginning:

    
    server {
      server_name sitetoredirect.com;
      return  301 http://sub.domain/portal/$request_uri;
    }
    Code (markup):
     
    tobalsan, Sep 11, 2013 IP