skip to Main Content

I have a special path in my site that should read files from another directory in my server.

 server {
  server_name www.translation1010.com translation1010.com;

    root /var/www/translation1010.com/;


    error_log /var/www/translation1010.com/_error.log;
  index index.php;



  #include /etc/nginx/options;

}

i want
translation1010.com/admin/
read from
/var/www/admins.com/panel/

what code should i use in ngnix?

2

Answers


  1. try this

    server {
      server_name www.translation1010.com translation1010.com;
    
      error_log /var/www/translation1010.com/_error.log;
      index index.php;
      location / {
         root /var/www/translation1010.com/;
      }
    
      location /admin/ {
         root /var/www/admins.com/panel/;
      }
    }
    
    Login or Signup to reply.
  2. make sure /admin location in front of /

    recommended to use alias, it direct pointing to /var/www/admins.com/panel/ instead of /var/www/admins.com/panel/admin

     server {
      server_name www.translation1010.com translation1010.com;
      location /admin/ {
         alias /var/www/admins.com/panel/;
      }
      location / {
         alias /var/www/translation1010.com/;
      }
      error_log /var/www/translation1010.com/_error.log;
      index index.php;
    
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search