nginx:如何创建别名url路由?

时间:2014-01-28 07:53:00

标签: nginx

基本上服务器实例正在

运行
somesite.com/production/folder/here?param=here&count=1

我想将someite.com/demo指向/production/folder/here,因此当用户输入somesite.com/production/demo?param=here时,它无需重定向到/production/folder/here

1 个答案:

答案 0 :(得分:59)

server {
  server_name example.com;
  root /path/to/root;
  location / {
    # bla bla
  }
  location /demo {
    alias /path/to/root/production/folder/here;
  }
}

如果您需要在try_files内使用/demo,则需要将alias替换为root,并因错误explained here而重写