Get the most out of your Centmin Mod LEMP stack
Become a Member

Nginx Redirect subdomain to a folder but keep the link on browser

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by pamamolf, Nov 14, 2014.

  1. pamamolf

    pamamolf Well-Known Member

    2,819
    251
    83
    May 31, 2014
    Ratings:
    +445
    Local Time:
    11:23 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Hi

    On a domain domain.com i have a folder inside named /knowledgebase/ and i create a sub domain kb.domain.com that i want to point to this folder on the main vhost account but to keep the subdomain on the browser for the user.

    Just to display the content from this folder from the main domain....

    How can i do that?

    I was think to adjust the config for the sub domain but i am not sure how to do it :(

    Code:
    #server {
    #  listen  80;
    #  server_name kb.domain.com;
    #  return 301 $scheme://www.kb.domain.com$request_uri;
    #  }
    
    server {
      server_name kb.domain.com www.kb.domain.com;
      
    I was try also:

    Code:
    location /home/nginx/domains/domain.com/public/knowledgebase {
    
    And point the subdomain to main domain path but was not working....
     
    Last edited: Nov 14, 2014
  2. eva2000

    eva2000 Administrator Staff Member

    30,921
    6,909
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,405
    Local Time:
    7:23 PM
    Nginx 1.13.x
    MariaDB 5.5
    for kb.domain.com vhost try changing the root path to /home/nginx/domains/domain.com/public/knowledgebase ?
     
  3. pamamolf

    pamamolf Well-Known Member

    2,819
    251
    83
    May 31, 2014
    Ratings:
    +445
    Local Time:
    11:23 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Ops sorry i was set location and not root path :(

    Checking now....
     
    Last edited: Nov 14, 2014
  4. pamamolf

    pamamolf Well-Known Member

    2,819
    251
    83
    May 31, 2014
    Ratings:
    +445
    Local Time:
    11:23 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Yes now is working great and i can see the content from this folder :)

    But on the browser is redirecting to main domain.com and not keep the subdomain :(

    Is there anyway to keep the subdomain on browser ?