2013-07-11 4 views
1

이미지, css 및 js dynamic을 삽입하고 싶습니다. 폴더 테마가 있고 거기에 여러 테마가 있습니다.htaccess에서 상위 폴더를 가져 오는 방법은 무엇입니까?

내 응용 프로그램의 구조 아래. 이 테마 폴더는 루트에 있습니다.

Structure

나는 나의 htaccess로이 기록을 추가 한 :

RewriteRule ^(css|js|img)/(.*)$ /themes/default/$1/$2 

그리고 내 경로가 같이 연결됩니다 :

/css/style.css    http://site.com/themes/default/css/style.css 
/js/someLib.js    http://site.com/themes/default/js/someLib.js 
/img/background.jpg  http://site.com/themes/default/img/background.jpg 

가 지금은 동적하기 위해 default 디렉토리를 원하는 .

나는이

RewriteRule ^(css|js|img)/(.*)$ ../$1/$2 

같은 것을 시도 그리고 그 결과 :(

+0

이상하게 나던 작품. ..'RewriteRule^(. +)?/(css | js)로 시도하십시오. | img)/(. +) $/themes/$ 1/$ 2/$ 3'입니다. '? '는 첫 번째 슬래시를 찾자 마자 멈추게한다. 어쩌면'(. *)'의 문제 일 것이다. –

+0

@PaoloStefan 감사합니다. 그러나 '500 내부 서버 오류'가 발생했습니다. 아마'RewriteCond % {HTTP_HOST}/(. +)/(css | js | img)'로 뭔가가 필요 하겠지만 사용법을 모르겠다. ( –

답변

1

이 코드를 시도하지 않고

/default/css/style.css 
RewriteRule ^(.*)/(css|js|img)/(.*)$ /themes/$1/$2/$3 

그러나

을 시도 :

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)/((?:css|js|img)/.+)$ /themes/$1/$2 [L,NC] 
+0

고마워!/css/style.css' –

+0

당신에게 환영받은 것을 기쁘게 생각합니다. – anubhava

관련 문제