2014-01-22 3 views
0

우리는 Laravel 프레임 워크를 사용하는 웹 사이트에서 새로운 섹션을 소개합니다. 하위 디렉터리에 배치됩니다 (예 : /newsection). 이전의 다시 쓰기 규칙과 충돌하지 않고 nginx.conf를 어떻게 설정해야합니까?중첩 된 Laravel 프로젝트 Nginx 구성

이는 내가 일을 알고있는 대부분의 프레임 워크처럼 작동하는 경우이 404의 대체 URI에 추가 /newsection을 제거하려고 반환하면 내 현재 nginx.conf

server { 
     listen 80; 
     server_name localhost www.website.com; 
     root /home/www/website; 
     index index.html index.php; 

     location /newsection/ { 
      rewrite ^/ /newsection/public/index.php last; 
      # this is my attempt at it 
     } 

     location/{ 
      try_files $uri $uri/ @rewrite; 
     } 

     location /php-status { 
      fastcgi_pass unix:/var/run/php-fpm.sock; 
      fastcgi_param SCRIPT_FILENAME $request_filename; 
      include fastcgi_params; 
     } 


     location @rewrite { 
      rewrite ^/([\w_-]+)/?$ /index.php?page=$1 last; 
      rewrite ^/([\w_-]+)/([\w_-]+)/?$ /index.php?page=$1&slug=$2 last; 
      rewrite ^/([\w_-]+)/([\w_-]+)/([\w_-]+)/?$ /index.php?page=$1&slug=$2&pagination=$3 last; 
      } 

     include php.conf; 
    } 

답변

1

,이

location /newsection/ { 
    try_files $uri $uri/ /newsection/public/index.php$request_uri; 
} 

작동합니다입니다 the try_files

+0

나는 환자가 아니므로 하위 도메인 솔루션을 사용하기로 결정했습니다. 시간을 찾으면 나는 당신의 답을 시험 할 것입니다. 감사. – bukka

0

laravelin 하위 디렉토리에 사용해보기

location ^~ /laravel { 
alias /var/www/laravel/public; 
try_files $uri $uri/ @laravel; 

location ~ \.php { 
    fastcgi_pass unix:/var/run/php5-fpm.sock; 
    fastcgi_split_path_info ^(.+\.php)(.*)$; 
    include /etc/nginx/fastcgi_params; 
} 
} 


location @laravel { 
    rewrite /laravel/(.*)$ /laravel/index.php?/$1 last; 
}