Nginx特殊文件夹指向另一个目录

时间:2018-11-14 07:36:20

标签: php linux apache nginx

我的网站中有一个特殊路径,该路径应从服务器中另一个目录读取文件。

 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;

}

我要 translation1010.com/admin/ 读自 /var/www/admins.com/panel /

我应该在ngnix中使用什么代码?

2 个答案:

答案 0 :(得分:0)

尝试

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/;
  }
}

答案 1 :(得分:-1)

确保/ admin位置位于/前面

建议使用别名,它直接指向/var/www/admins.com/panel/而不是/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;

}