2016-09-28 6 views
0

에 대한 단일 디렉토리 서버는 내가 경로/사용자, 즉 시작하면 80의 nginx - 중첩 된 경로

가 지금은 다른 디렉토리 (share1)에서 제공 할 포트에서 수신하도록 $ 루트로 기본 루트 디렉토리를 설정 한/사용자/사용자/XYZ,/사용자/ABC 방송 모든 것은 ... 한마디로

map $http_user_agent $root { 
    "~*android" /home/vishant/devcenter/wava-v1.1/android; 
    "~iPhone" /home/vishant/devcenter/wava-v1.1/ios; 
    default /home/vishant/devcenter/wava-v1.1/ios; 
} 

server { 
    listen 80; 

    root $root; 
    index index.html; 

    location /user { 
      alias /home/vishant/devcenter/share1; 
    } 
} 

내가이 정확하지의 below..though 뭔가를 원하는 ... share1 디렉토리에서 역할을해야한다

location /user/* { 
    alias /home/vishant/devcenter/share1; 
} 

/user (/ user/abc,/user/xyz)로 시작하는 모든 요청을 index.html 파일에 기록해야합니다.

답변

0

명확하고 잘 작동하려면 메인 //user을 루트로 나눌 수 있습니다.

map $http_user_agent $root { 
    "~*android" /home/vishant/devcenter/wava-v1.1/android; 
    "~iPhone" /home/vishant/devcenter/wava-v1.1/ios; 
    default /home/vishant/devcenter/wava-v1.1/ios; 
} 

server { 
    listen 80; 

    location/{ 
     root $root; 
     index index.html; 
    } 

    location /user { 
     alias /home/vishant/devcenter/share1; 

     rewrite ^(.*)$ /user/index.html last; 
    } 
} 

이 지정된 경로에 /user로 시작하는 모든 및 별칭을 일치해야합니다.

+0

이 것을 구현하려했으나 작동하지 않았습니다./user/abc가 여전히 404가 없습니다. –

+0

파일이 존재합니까? ;) – sokoli

+0

나는 index.html 파일 만 가지고 있으며 index.html을 호출하려고합니다. 다른 사람들은 아닙니다. –