2012-10-28 3 views

답변

1

당신은 당신의 .htaccess에서 정확한 라인을 가지고 있지만, 당신은 단지 필요 에서 [L] 플래그를 변경 [L, R = 301] 참고로 변경해야

RewriteCond %{REQUEST_FILENAME} !-f #checks if current URI leads to real file 
RewriteCond %{REQUEST_URI} !(.*)/$ #checks if URI ends by slash, if not goes next 
RewriteRule ^(.*)$ http://paweljanicki.pl/$1/ [L] #this line changes a URI 

:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !(.*)/$ 
RewriteRule ^(.*)$ http://paweljanicki.pl/$1/ [L,R=301] #or skip 301 code [L,R] 
#R=302 by default, but you can set any valid HTTP response status code 300-399 

키 I s [L] 플래그는 브라우저로 리디렉션을 출력하지 않지만 Apache는 website.pl/page URI (예 : website.pl/page/)를 처리합니다.

자세한 내용은 Apache 문서 도구 RewriteRule Flags

+0

고맙습니다. 그것은 작동합니다! –

+0

이 질문을 "답변 됨"으로 표시하려면 어떻게해야합니까? 나는 그것을 어디서나 찾을 수 없기 때문에. –

0

기본적으로 mod_dir은 DirectorySlash 지시어 (기본적으로 "On"으로 설정 됨)를 통해 사용자를 대신합니다. 이것은 아파치가 당신의 요청이 디렉토리를위한 것이라고 생각하고 후행 슬래쉬가 없다면, mod_dir은 요청을 슬래시로 리다이렉트 (301) 할 것이다.

그러나 CMS의 가상 디렉토리 나 아파치에서는 mod_dir이 후행 슬래시를 처리해야한다는 것을 깨닫지 못합니다. 따라서 기존의 파일이나 디렉토리, 또는 기존 디렉토리를 가리 키지 않는 모든 것에 후행 슬래시를 추가하고 * mod_dir *을 해제 할 수 있습니다. 문서 루트의 htaccess로 파일에서

, 당신이 이미있을 수 있습니다 라우팅 규칙 모든 유형의 위 (이러한 규칙을 추가

DirectorySlash Off 

RewriteEngine On 

# if request is for a directory 
RewriteCond %{REQUEST_FILENAME} -d 
# and is missing the trailing slash 
RewriteRule ^(.*[^/])$ /$1/ [L,R=301] 

# if request isn't for an existing directory or a file 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
# and no trailing slash 
RewriteRule ^(.*[^/])$ /$1/ [L,R=301] 
관련 문제