2012-05-07 5 views
2

그래서 저는 apache에서 NginX로 응용 프로그램을 옮기려고합니다.하지만 .htaccess 파일을 다시 작성해야한다는 것을 발견했습니다. 도움을 청하기..htaccess to nginx 특정 폴더를 제외하고 규칙을 다시 작성하십시오.

다음은 /html,/css,/images,/php에 대한 요청을 제외한 모든 요청을 index.php로 리디렉션하려고하는 apache의 .htaccess 파일입니다.

미리 도움을 주셔서 감사합니다. 빌

RewriteEngine on 
RewriteRule ^html [L,NC] 
RewriteRule ^css [L,NC] 
RewriteRule ^images [L,NC] 
RewriteRule ^php [L,NC] 
RewriteRule ^.*$ index.php [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !directory/(.*)$ 
RewriteCond %{REQUEST_URI} !(.*)$ 
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] 

은 지금까지 나는 아래이 있고 HTML, CSS, 이미지 및 PHP 파일에 대한 요청은 큰 노력하고 있습니다.

하지만 내가 404를 얻는 www.domain.com/blah/blah/blah/ 메신저를 요청하면, 내가 정말로 원하는 것은 www.domain.com/blah/blah/blah로 reamin하는 URL입니다. ,

RewriteEngine On 
# if not requesting content in one of the specified folders 
RewriteCond %{REQUEST_FILENAME} !^(html|css|images|php)/ [NC] 
# redirect visitor to the index page 
RewriteRule ^(.*)$ index.php [L,QSA] 

가 재 작성 조건 전에 느낌표가 부정을 의미한다 (!) : /하지만

location ~ directory/(.*)$ { 
} 

location ~ (.*)$ { 
} 

location /html { 
rewrite ^/html/break; 
} 

location /css { 
rewrite ^/css/break; 
} 

location /images { 
rewrite ^/images/break; 
} 

location /php { 
rewrite ^/php/break; 
} 

location/{ 
rewrite ^(.*)$ /index.php break; 
if (!-e $request_filename){ 
rewrite ^(.*)$ http://www.domain.com/$1 redirect; 
} 
} 

답변

0

특정 폴더에 컨텐츠 필터링 요청이 라인을 따라 뭔가를보십시오 index.php 파일을로드 그래서 요청한 파일 이름이 html이나 css 또는 ....로 시작하지 않으면 다시 쓰기 규칙을 적용하십시오.

+0

덕분에 톰, 그것은 나에게주는 연구하면서 볼 컨버터 필자을 .. 사용 는'경우 을 code' ($의 REQUEST_FILENAME ~ *! "^ (HTML | CSS | 이미지 | PHP) /") { \t 세트 $ rule_0 1 $ rule_0; } if ($ rule_0 = "1") { \t 다시 쓰다 ^/(. *) $ /index.php last; }'code' – Bill

관련 문제