2009-12-17 7 views
1

나는 서브 디렉토리 내가 codeginiter 프레임 워크와 함께 일하고 내 디렉토리 구조가 보이는 http://www.domain.com/trac/코드 점화 하위 디렉토리 질문

URL을 통해 액세스 할 수 년대 "TRAC"디렉토리와 그 모든 있도록 노력하고

.htaccess 
index.php 
system 
trac 
같은

abov url에 액세스 할 수 있지만 문제는 trac 하위 디렉토리에있는 스크립트 및 기타 파일입니다. 예 : trac/chrome/common/css/trac.css는 액세스 할 수 없으며 404입니다. 여기에 내 .htaccess 코드가 있습니다. 도와주세요.

RewriteEngine On 
RewriteRule ^$ index.php [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
RewriteCond $1 !^trac/ 
RewriteRule ^trac/(.*) /trac/$1 

답변

0

마지막 두 줄을 제거하면 제대로 작동합니다.

RewriteCond %{REQUEST_FILENAME} !-f은 파일을 요청하지 않았는지 확인합니다. 그렇다면이 조건이 실패하고 RewriteRule ^(.*)$ index.php?/$1 [L] 규칙이 실행되지 않습니다.

1

재 작성 규칙은 순서대로 실행 ... 그래서이

RewriteCond %{REQUEST_URI} !^/trac/ 
RewriteCond $1 !(index\.php/) 
RewriteRule ^(.*)$ index.php?/$1 [L] 

설명을 시도하고 있습니다 :

if the uri DOES NOT start with trac 
if the uri IS NOT index.php 
rewrite url as index.php?/{rest of the url} 
2

당신은 심지어 당신의 .htaccess에// TRAC 언급 할 필요가 없습니다. 정확히 정확히

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

두 개의 "다시 쓰기 조건"을 설정하고 있습니다. 첫 번째 질문은 "요청이 파일이 아닌 한"입니다. 두 번째는 "요청이 디렉토리가 아닌 한"이라고 말합니다.

그런 다음

RewriteRule ^(.*)$ index.php?/$1 [L] 

은 CI가 점거의 index.php에 다른 모든를 보냅니다. 그리고 그냥 모든 프로젝트에서 사용 기록, 내 전체의 .htaccess에 대해 : 당신이 RewriteCond %{REQUEST_URL} ^system.* 라인에 대한 혼란이 있다면 어떤 브라우저가/시스템에 요청하도록

Options +FollowSymLinks 

RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 

, 그것은 단지 존재/폴더는 항상 index.php로 라우팅되므로 무시됩니다.