문제

처음 내 사이트를 설정했을 때 추가하기로 결정했습니다. index.html URL에 있지만 이제 사람들이 제거 할 때 문제가 있습니다. index.html 폴더에 액세스하려고 시도하십시오 ...

예를 들어:

RewriteRule ^archives/([0-9]+)/([0-9]+)/index.html archive.php?mid=$1-$2

그렇게 할 때 archives/07/2009/ 오류가 발생하면이 오류를 피할 수있는 방법은 무엇입니까? 건배

도움이 되었습니까?

해결책

만들기 index.html 귀하의 선택 사항 RewriteRule:

RewriteRule ^archives/([0-9]+)/([0-9]+)/(?:index\.html)?$ archive.php?mid=$1-$2

또한 원래의 재 작성 규칙에서 문자열 앵커의 끝을 잊었습니다. $. 위에 추가했습니다.

다른 팁

이 규칙은 선택 사항을 사용해보십시오 index.html:

RewriteRule ^archives/([0-9]+)/([0-9]+)/(index\.html)?$ archive.php?mid=$1-$2

그러나 나는 당신이 후행의 유무에 관계없이 두 가지 표기법 중 하나를 고수하는 것이 좋습니다. index.html 잘못된 경우 리디렉션 :

# remove index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*/)?index\.html$ /$1 [L,R=301]

# add index.html
RewriteRule (.*)/$ $1/index.html [L,R=301]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top