2012-07-14 2 views
2

요즘 CodeIgniter를 사용하려고합니다. 기본적으로.htaccess는 상대 링크 문제로 index.php를 숨 깁니다.

그것은 컨트롤러

내부의 기능이

http://www.example.com/index.php/home 

home 같은 URI에서의 index.php이다 가지고하지만 난 index.php 그래서 나는 htaccess로 파일을 생성하지 않으 :

Allow from all 
RewriteEngine On 
RewriteBase/

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

RewriteCond $1 !^(index\.php|img|robots\.txt|script|css) 
RewriteRule ^(.*)$ index.php/$1 [L] 

기본적으로 conds가 일치 할 때를 제외하고 "index.php"가 자동으로 추가됩니다. 이 같은 URI를 들어
:

그러나 여기에 일이 http://www.example.com/home
모든 것이 잘 작동합니다.

다음과 같은 URI의 경우 : http://www.example.com/home/
내 웹 페이지의 상대 링크는 자연스러워집니다.
예 : css/common.cssindex.php/home/css/common.css으로 리디렉션되어 css 파일을 찾을 수 없습니다.

로그는 다음과 같습니다

strip per-dir prefix: [dir to my site]/home/css/common.css -> home/css/common.css 
applying pattern '^(.*)$' to uri 'home/css/common.css' 
rewrite 'home/css/common.css' -> 'index.php/home/css/common.css' 
add per-dir prefix: index.php/home/css/common.css -> [dir to my site]/index.php/home/css/common.css 
trying to replace prefix [dir to my site]/ with/
internal redirect with /index.php/home/css/common.css [INTERNAL REDIRECT] 
add path info postfix: [dir to my site]/index.php -> [dir to my site]/index.php/home/css/common.css 
strip per-dir prefix: [dir to my site]/index.php/home/css/common.css -> index.php/home/css/common.css 
applying pattern '^(.*)$' to uri 'index.php/home/css/common.css' 
pass through [dir to my site]/index.php 

나는이 문제를 해결할 수있는 방법?

+0

로그를 추가하는 경우 +1! – Ansari

답변

2

여기의 문제는 다시 쓰기 규칙이 아니라 문제가 아닙니다. 브라우저에서 /home/은 슬래시가 실제 디렉토리라고 생각하기 때문에 브라우저가 생각하는 디렉토리의 모든 상대 링크를 접두사로 사용합니다. 그런 다음 브라우저는 CSS 파일에 대한 요청을 대시합니다 (경로 /home/css/common.css). 귀하의 수표와 일치하지 않으므로 당연히 다시 작성됩니다.

가장 빠른 해결책은 CSS 파일의 절대 경로를 사용하는 것입니다. 지금 상대 링크 대신 /css/common.css 링크 만 연결하면됩니다.

+0

사실 내 사이트에서 그런 링크를 많이 사용합니다. 모든 링크가 내 페이지에서 생성되는 한 괜찮습니다. 그래서이 문제를 무시할 수 있을까요? – NSF

+0

무시해도 될지 모르겠다. CSS 파일을 찾을 수 없으면 영향을받지 않는가? – Ansari

+0

네,하지만 링크가 내 페이지에 의해 생성되는 한 마지막 슬래시가 포함되지 않고 잘 작동하는 것 같습니다. – NSF

관련 문제