2011-09-23 6 views
1

클라이언트가 * .pdf 또는 * .cdr 파일을 요청하면 다른 사이트 (저장소)로 리디렉션하려고합니다.htaccess 특정 파일 확장명의 다른 사이트로 리디렉션

아래의 htaccess와 함께 cdr 다운로드가 작동하지만 pdf는 문제가되지 않습니다. 규칙 순서 (cdr first, pdf second)를 변경하면 pdf가 작동하지만 cdr은 작동하지 않습니다.

[OR] 다른 정규식을 두 패턴 모두 한 패턴으로 잡으려고 시도했습니다. 이것은 유일한 작품입니다 (반 작품). 리디렉션이 인 파일 (pdf 또는 cdr)은 (FTP를 통해 확인)입니다.

나는 현재 루트의 .htaccess에 있습니다

#<snip> 

RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 

# catch site.ro/some_file.pdf 
RewriteCond %{REQUEST_URI} (.+pdf)$ [NC] 
RewriteRule ^(.*)$ http://docs.site.com/$1 [L,R] 

# catch site.ro/some_file.cdr 
RewriteCond %{REQUEST_URI} (.+cdr)$ [NC] 
RewriteRule ^(.*)$ http://docs.site.com/$1 [L,R] 

RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 

답변

1

이 내가 할 것 인 것이다 :

RewriteCond %{REQUEST_FILENAME} !-d    # If not an existing directory 
RewriteCond %{REQUEST_FILENAME} !-f    # If not an existing file 
RewriteCond %{REQUEST_URI} \.(pdf|cdr)$ [NC]  # If filename ends with .pdf or .cdr 
RewriteRule ^(.*)$ http://docs.site.com/$1 [L,R] # Redirect the user to the other site 

RewriteRule ^.*$ index.php [NC,L]  # Redirect all other requests to index.php 

희망이 당신에게

+0

자, 이제 그들 중 누구도 작동하지를하는 데 도움이됩니다. – nevvermind

+1

취소하십시오. 이 작동합니다. 감사. – nevvermind

관련 문제