2015-02-05 7 views
0

파일이나 폴더가 실제로 존재하지 않는 한 모든 URL을 index.php로 다시 작성하는 프레임 워크를 사용하고 있습니다..htaccess 기본 폴더를 다시 쓰지만 내용이 없습니다.

# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# Rewrite all other URLs to index.php/URL 
RewriteRule .* index.php/$0 [PT,L] 

그러나 'media'라는 디렉토리와 '/ media'라는 URL이있는 페이지가 있습니다. 나는 그것을 만들 필요가있다. '/ media'가 index.php로 라우팅되지만, 을보고 안에 'media'디렉토리가 평소대로 표시된다.

은 그래서 :

http://example.com/some-page - routed through index.php (already does this) 
http://example.com/media - routed through index.php as well 
http://example.com/media/images/hello.jpg - asset served as usual 

나는 시도했다 :

RewriteRule ^media$ index.php/media [PT,L] 

이 평소와 '미디어'폴더의 내용을 나열합니다.

RewriteRule ^media/$ index.php/media 

이로 인해 리디렉션 루프가 발생합니다.

나는 다른 구문이 어떻게 작동하는지 확신 할 수 없습니다.

답변

1

/media/images/hello.jpg가 실제 파일 인 경우 RewriteCond %{REQUEST_FILENAME} !-f은 이미 이것을 무시하고 있습니다.

그렇지 않으면 당신은 기존 라우팅 규칙 전에이 규칙 장소 :

RewriteRule ^media/.+$ - [NC,L]