2017-02-18 1 views
0

안녕하세요. www.example.com을 도메인으로 운영하는 웹 사이트를 운영하고 있습니다. 또한 같은 웹 사이트에 웹 응용 프로그램이 있지만 디렉토리에 www.example.com/app/을 말할 수 있습니다. 이제 응용 프로그램에는 www.example.com/app/a와 같은 다른 디렉토리가 있습니다. 디렉토리에 대해 다른 오류 404 페이지를 어떻게 설정할 수 있는지 알고 싶었습니다. 첫 번째 경우를 들어 나는이를 사용하여 작업을 수행 할 수 있습니다 알고 : -nginx에서 다른 디렉토리에 다른 404 오류 페이지를 설정하는 방법은 무엇입니까?

error_page 404 /error404.html; 
location = /error404.html { 
     root /usr/share/nginx/html; 
     internal; 
} 

내가 다른 디렉토리에 다른 페이지를 설정할 수있는 방법을 알고 싶어. 누구든지 도울 수 있다면 매우 감사 할 것입니다.

답변

0

다음 단계에 따라

1.Create 2 사용자 정의 err1.html

2.Change err2.html 이름 404 페이지를 다음과 같이 귀하의 설정 :

server { 
    listen  80; 
    server_name localhost; 
    location/{ 
     root /usr/share/nginx/html; 
     index index.html index.htm; 
    } 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root /usr/share/nginx/html; 
    } 
    location /app { 
     error_page 404 /err1.html; 
    } 
    location /loc { 
     error_page 404 /err2.html; 
    } 
    location = /err1.html { 
     root /usr/share/nginx/html; 
    } 
} 

당신이 /app로 이동 너는 err1.html을 얻을 것이고, /loc은 너를 줄 것이다 err2.html

관련 문제