2010-11-27 2 views
1

302 리디렉션 .php 나는 $ _SERVER [ 'REQUEST_URI']를 사용하여 사용자가보고 싶은 페이지 (예 : /testfile.php)를 확인하므로 index.php가 적절한 html 코드를 생성 할 수 있습니다. testfile.php가 존재할 필요는 없다.nginx를 대신 재 (200)

제 문제는 testfile.php을 요청하려고 할 때 항상 리디렉션 302가 발생한다는 것입니다. 결과적으로 $ _SERVER [ 'REQUEST_URI']는 /입니다. 하지만 내가 원하는 것은 testfile.php에 대해 200 OK이고 index.php는 이에 대한 올바른 html 코드를 생성합니다.

server { 
[...] 

    root /home/test; 

    # When I go to mysite.com redirect my to mysite.com/ 
    location =/{ 
    index index.php; 
    } 

    # For any php file request: let index.php handle the request 
    location ~ \.(php)$ { 
    include fastcgi_params; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_param SCRIPT_FILENAME /home/test/index.php; 
    } 
} 

누구든지 나를 도울 수 있습니다

이 내 버그 nginx.conf에서 조각은 무엇입니까? 감사합니다. .

답변

0

파일이 존재하지 않을 경우이 작업을 수행 할 수 있습니다

location/{ 
    rewrite ^.*$ /index.php last; 
} 

두 경우 모두 당신이 원래 요청을 읽을 수 있어야 :

try_files $uri $uri/ /index.php 

당신은 또한이 같은 요청을 다시 작성할 수 있습니다 PATH_INFO 또는 REQUEST_URI

좀 더 제안이 링크를 살펴 유무 : http://drupal.org/node/110224, http://michaelshadle.com/2010/08/20/front-controller-patterns-and-nginx/Zend Framework on nginx