2014-09-30 2 views
0

a/<SEGMENT> 부분은 x 또는 y을 제외하고 세그먼트를 다시 작성해야합니다. nginx에서 어떻게합니까? 아파치에서는 다음 규칙을 통해이를 수행합니다 :독점적 인 재 작성

RewriteCond %{REQUEST_URI} !^/a/x 
RewriteCond %{REQUEST_URI} !^/a/y 
RewriteRule ^a/(.+)$ script.php 

감사합니다!

답변

0

일반적으로 nginx는 가장 구체적인 위치를 먼저 찾습니다. 따라서/a/x 또는/a/y가 일치하지 않으면 기본 위치 /는 다음과 일치합니다.

location/{ 
    try_files /script.php =404; 
    fastcgi_pass unix:/var/run/php5-fpm.sock; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
} 

location ~ ^/a/(?:x|y) { 
    try_files $uri $uri/ =404; 
}