Learn about Centmin Mod LEMP Stack today
Register Now

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 Premium Member Premium Member

    4,070
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    6:43 PM
    Nginx-1.25.x
    MariaDB 10.3.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

    53,558
    12,135
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,678
    Local Time:
    1:43 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    for kb.domain.com vhost try changing the root path to /home/nginx/domains/domain.com/public/knowledgebase ?
     
  3. pamamolf

    pamamolf Premium Member Premium Member

    4,070
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    6:43 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    Ops sorry i was set location and not root path :(

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

    pamamolf Premium Member Premium Member

    4,070
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    6:43 PM
    Nginx-1.25.x
    MariaDB 10.3.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 ?