2010-12-20 2 views
0

에 내가 지금까지 사용하고 특정 폴더, 즉에 이미지와 다른 정적 파일에 대한 URL을 다시 작성하는 방법은 :htaccess로 - RewriteRule의 정적 파일

RewriteRule \.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt)$ /MyFolder/$1 

하지만이 작동하지,

은 도움을 주시기 바랍니다.

------------------- 업데이트 ---------------------

그래서 지금은이 :

RewriteCond %{HTTP_HOST} ^(www.)?exmpale.com$ 
RewriteCond %{REQUEST_URI} !^/exmpale.com/ 
RewriteRule ^(.*\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt))$ /exmpale.com/$1 

RewriteCond %{HTTP_HOST} ^(www.)?exmpale.com$ 
RewriteRule !\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt)$ /exmpale.com/index.php 

이렇게 폴더를 exmpale로 리디렉션 이미지는 작동하지만 지금이 솔루션은 지금까지 작동하지 않습니다 위의 index.php에 다른 모든를 다시 작성하고 싶습니다.

환호, 이/마르신 어쩌면 이것은 당신이 원하는

답변

4

:

RewriteRule ^(.*\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt))$ /MyFolder/$1 

혹은이 :

RewriteRule ([^/]*\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt))$ /MyFolder/$1 

그 중 어느 것도 당신이 찾고있는 경우하시기 바랍니다 원하는 입/출력의 예와 함께 세부 사항을 추가하십시오.

업데이트의 경우이 규칙이 일치 할 때 L 플래그를 사용하여 규칙 처리를 중지하고 싶을 수 있습니다. 예 :

RewriteCond %{HTTP_HOST} ^(www.)?exmpale.com$ 
RewriteCond %{REQUEST_URI} !^/exmpale.com/ 

# The next line is long. Scroll to the end! 
RewriteRule ^(.*\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt))$ /exmpale.com/$1 [L] 

RewriteCond %{HTTP_HOST} ^(www.)?exmpale.com$ 
RewriteRule .* /exmpale.com/index.php 
+0

거의 거기, 제 질문을보십시오 – Marcin

+0

+1 간결하고, 단서 포착을 위해. –

+0

내 업데이트를 살펴보고 알려주십시오. – Marcin

0

초기 요청을 캡처하지 않습니다. 다음을 시도해보십시오 :

RewriteRule (.*)\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt)$ /MyFolder/$1.$2 

이 지정 예를 들어 /MyFolder/에서 재 연장에 종료 아무것도 얻을 것이다 : 지금로 이동합니다 /something/image.jpg/MyFolder/something/image.jpg

참고 :는이 작업을 수행하는 더 나은 방법이있을 수 있습니다 파일 유형을 확인하기위한 조건을 추가합니다.