nginx重定向到父目录而不是子目录

时间:2016-03-15 12:06:45

标签: php apache nginx laravel-5.1 ubuntu-14.04

nginx默认配置文件

server {
  listen          80;
  server_name     domain.com;
  root            /var/www/html/laravel5-1.0/;
  index       index.php;

  location / {
   try_files $uri $uri/ /index.php;
   proxy_redirect off;
   proxy_set_header Host $host:$server_port;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-Host $host;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

   #proxy_cache web_cache;
   add_header X-Proxy-Cache $upstream_cache_status;

   proxy_pass http://localhost:8081/;
  }


  # CSS and Javascript
  location ~* \.(?:css|js)$ {
    expires 1y;
    access_log off;
    add_header Cache-Control "public";
  }

}

问题:nginx指向www目录而非laravel5-1.0目录应用程序类型为laravel

laravel5是我的应用程序的公共目录 nginx和apache在同一个虚拟主机上运行 nginx端口80 apache2 8081

请帮我将页面访问权限重定向到laravel5-1.0目录

1 个答案:

答案 0 :(得分:1)

try_files就是这样,它检查$uri如果找不到,它将在proxy_pass之前进行内部重定向到/index.php。 所以,如果你删除该行 try_files $uri $uri/ /index.php;

它将到达{_ 3}}

的proxy_pass

文档: http://localhost:8081/

相关问题