2014-05-14 2 views
0

나는 이와 같은 .htaccess를 가지고 있습니다. 내가 세 개의 디렉토리와 이미지가 될 때까지Apache - RewriteCond % {REQUEST_FILENAME}! -f

Options FollowSymLinks 
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^media/([^/]+) download.php?file=$1 [L] 
RewriteRule ^json/([^/]+)/([^/]+)/([^/]+) jsonfeed.php?module=$1&method=$2&params=$3 [L] 
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?q=$1,$2,$3,$4 [NC,L] 

모든 것이 잘 작동합니다. 예를 들면 다음과 같습니다.

http://localhost/upload/html/.thumbs/2.jpg 

이 마지막 규칙과 유사한 URL이 적용됩니다. 파일이 존재합니다. 엔진을 다시 작성하지 않고도 정상적으로로드됩니다. 내가 뭘 잘못하고있어?

+0

은'RewriteCond' 세트는 다음 중 하나에만 적용' – Deadooshka

답변

0

이 문제는 [L] 지시문을 사용 했음과 관련이 있습니다. 후속 규칙은 존재 확인 또는 디렉토리 확인의 성공 또는 실패 여부를 고려하지 않습니다.

Options FollowSymLinks 
RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^media/([^/]+) download.php?file=$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^json/([^/]+)/([^/]+)/([^/]+) jsonfeed.php?module=$1&method=$2&params=$3 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?q=$1,$2,$3,$4 [NC,L] 

더 컴팩트 한 솔루션은 먼저 기존의 것들을 다루는과 같이하는 것입니다 : 다음과 같이 하나 개의 솔루션은

Options FollowSymLinks 
RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule .* - [L] 

RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule .* - [L] 

RewriteRule ^media/([^/]+) download.php?file=$1 [L] 
RewriteRule ^json/([^/]+)/([^/]+)/([^/]+) jsonfeed.php?module=$1&method=$2&params=$3 [L] 
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?q=$1,$2,$3,$4 [NC,L] 
+0

을 RewriteRule' 매력처럼 작동합니다. 고맙습니다. – Neevor

관련 문제