2015-01-08 3 views
1

부모 디렉토리는 리디렉션하고 자식은 리디렉션하지 않으려면 어떻게해야합니까? 아래에서 내 특정 문제를 참조하십시오. 모든 도움을 주시면 감사하겠습니다!301 리디렉션 - 부모는 리디렉션하지만 자식은 리디렉션하지 않습니다.

부모 -

redirect 301 /community/whats-happening http://www.stapletondenver.com/whats-happening/ 
  • 는 상위 디렉토리를 리디렉션

아이 -

redirect 301 /community/whats-happening/celebrating-halloween-stapleton http://www.stapletondenver.com/whats-happening/celebrating-halloween-in-stapleton/ 

에 잘못 리디렉션합니다. 아래 참조 :

RewriteRule ^community/whats-happening/. /whats-happening/ [R=301,L] 

RewriteRule ^community/whats-happening/(.*)$ /whats-happening/$1 [R=301,NC,L] 

RewriteRule ^/?community/whats-happening/?$ http://www.stapletondenver.com/whats-happening/ [R=301] 

RewriteRule ^community/whats-happening/(.*) http://stapletondenver.com/whats-happening/$1 [R=301,L] 
RewriteRule ^community/whats-happening/(.*)/(.*)/? http://stapletondenver.com/whats-happening/$1/ [R=301,L] 

답변

6

첫 번째 리디렉션 때문에 이러한 현상이 발생합니다. Redirect 지침은 그래서, 모든 서브 디렉토리와 파일을 리디렉션

Redirect 301 /abcd http://domain.com/xyz 

  • /abcd/ 의미 ->http://domain.com/xyz/
  • /abcd/1234/ ->http://domain.com/xyz/1234/
  • /abcd/1234/z.html ->http://domain.com/xyz/1234/z.html

등 만 리디렉션 상위 디렉토리를 원하는 경우 $ 끝 문자와 정규식과 RedirectMatch 사용

:

RedirectMatch 301 ^/community/whats-happening/?$ http://www.stapletondenver.com/whats-happening/ 
RedirectMatch 301 ^/community/whats-happening/celebrating-halloween-stapleton/?$ http://www.stapletondenver.com/whats-happening/celebrating-halloween-in-stapleton/ 
+0

는 당신에게 자세한 설명 대단히 감사합니다, 좋은 작품! 리디렉션을 통해 항상 모든 유사 콘텐츠를 얻을 수 있습니다. 여기에 많은 것을 배웠습니다, 다시 한번 감사드립니다! – user2105735

관련 문제