2011-03-12 5 views
1

매우 간단한 5 페이지 정적 사이트가 있습니다.htaccess에서 ErrorDocument와 리디렉션을 결합하는 방법은 무엇입니까?

404 대신 방문자가 존재하지 않는 페이지에 액세스 할 때마다 색인 페이지로 301 리디렉션을 수행하려고합니다. 나는 다음과 같이 시도했다.

ErrorDocument 404 404.htm 
redirect 301 404.htm index.htm 

그러나 작동하지 않는 것 같다. 인덱스 페이지로 301 리디렉션을 수행하려면 어떻게해야합니까?

답변

2

이 페이지의 고정 된 목록이있는 경우 다음과 같은 일을 할 수있는 :

#map _all_ known pages on the site 
RewriteRule url1 page1.htm [NC, L] 
RewriteRule url2 page2.htm [NC, L] 
RewriteRule url3 page3.htm [NC, L] 
RewriteRule url4 page4.htm [NC, L] 
RewriteRule url5 page5.htm [NC, L] 

#if there's something that doesn't fit in the rules above then it means there's no such page so we redirect to home with a 301 
RewriteRule (.+) index.htm [R=301,L] 
+0

나 :이었다 RewriteRule의 URL입니다 ([0-9] +)의 문서 $ 1.htm [NC, L] –

+0

'one.html ','second.htm','third.htm','third.htm','third.htm'에 다시 써야 할'one, two, three, four, and five '라는 5 페이지를 가질 수있는 한 가지 예가 있습니다. .htm','fourth.htm' 및'fifth.htm'. 하나의 규칙으로는이 작업을 수행 할 수 없습니다. – CyberDude

관련 문제