skip to Main Content

I’ve got a shopify website called https://mydomain-com.

This website has 3 subdomains, that are pointing to another server ip (A- record). On my server I’ve got 1 main root folder. How can I make sure all 3 subdomains are pointing to that root folder?

Because right now it’s looking for the subdomain folder. I can’t point my root domain ip to the server because it’s a shopify website.

How can I make sure the subdomains are pointing to that 1 folder on my nginx server?

2

Answers


  1. You need to create configs for each subdomain. And specify root directory for those subdomains. Example:

    server {
       listen 80;
       server_name subdomain1.domain.com;
    
       root /path/to/directory;
       index index.html;
    }
    
    server {
       listen 80;
       server_name subdomain2.domain.com;
    
       root /path/to/directory;
       index index.html;
    }
    
    Login or Signup to reply.
  2. You can this in NGINX configuration file in your server

    server {
      listen 80;
      server_name _;
    
      root /path/to/directory;
    
      location / {
        try_files $uri $uri/ /index.html;
      }
    }
    

    However if you want to have different subdomains point to different folders, you can change the server_name value to the SUBDOMAIN-NAME as follows:

    server {
      listen 80;
      server_name subdomain1.domain.com;
    
      root /path/to/directory1;
    
      location / {
        try_files $uri $uri/ /index.html;
      }
    }
    
    
    server {
      listen 80;
      server_name subdomain2.domain.com;
    
      root /path/to/directory2;
    
      location / {
        try_files $uri $uri/ /index.html;
      }
    }
    
    
    server {
      listen 80;
      server_name subdomain3.domain.com;
    
      root /path/to/directory3;
    
      location / {
        try_files $uri $uri/ /index.html;
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search