2014-10-16 8 views
0

특정 경로 매개 변수에 대한 아파치에 URL을 다시 작성하는 방법 :이 같은 mod_rewrite를 함께 URL 재 작성을 수행 할

example.com/path/foo/rest_of_path-> example.com/path/rest_of_path (remove foo) 
example.com/path/bar/rest_of_path-> example.com/path/rest_of_path (remove bar) 
example.com/path/sample/rest_of_path-> no rewriting<br/> 
example.com/path/test/rest_of_path-> no rewriting 

foo는, 동적 테스트,이 정적 샘플입니다 나는 경로 목록을 가지고있다.

그래서 내가 (내을 httpd.conf에서)이 같은 일을 생각하고 :

RewriteCond ....... #it's here i'm blocking, how write only if $1 in test,sample ? 
RewriteRule ^path/(.\*)/(.*)$ /path/$2 

답변

0
# You can add as much RewriteCond as you need to exclude static words 
RewriteCond %{REQUEST_URI} !^/path/sample/.* 
RewriteCond %{REQUEST_URI} !^/path/test/.* 
RewriteRule ^path/(.*)/(.*) /path/$2 
+0

는 감사합니다,하지만 그리워 [OR] 플래그 : 한다 RewriteCond % {REQUEST_URI}! ^/path/sample /.* [OR] RewriteCond % {REQUEST_URI}! ^/path/test /.* –

+0

아니요, [OR]은 필요하지 않지만 AND는 암시 적입니다. 정적 단어 샘플이없고 경로에 정적 단어 테스트가없는 경우에만 RewriteRule을 적용해야합니다. 아니면 내가 너를 오해하니? –

+0

예, 맞았습니다. 감사합니다. –

관련 문제