2012-07-02 3 views
0

첫 번째 URL을 두 번째 URL로 리디렉션 할 수있는 방법이 있습니까?중복 사본 제거 (html 확장자와 비 html)


http://www.example.com/podcast/episode

같은 페이지의 중복 된 복사본으로 표시하지 않도록, URL의 HTML이 아닌 버전으로 리디렉션 할 .html 중에서 확장자를 강제로 어떤 방법이 있나요

http://www.example.com/podcast/episode.html. 순간

내 htaccess로 코드는 다음과 같습니다

RewriteEngine On 
    RewriteBase/

    #removing trailing slash 

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)/$ $1 [R=301,L] 

    #non www to www 

    RewriteCond %{HTTP_HOST} !^www\. 
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

    #shtml 

    AddType text/html .html 
    AddHandler server-parsed .html 

    #html 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^([^\.]+)$ $1.html [NC,L] 

    #index redirect 

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/ 
    RewriteRule ^index\.html$ http://example.com/ [R=301,L] 

이 가능합니까?

+0

문서 루트 또는 podcast 디렉토리에 .htaccess 파일이 있습니까? 이것은 정말로 중요한 세부 사항입니다. –

+0

@JonLin .htaccess가 문서 루트에 있습니다. – Jeremy

+0

무엇이 잘못되었는지 알지 못합니다. 규칙과 Tim Stoop의 규칙을 테스트 Apache 서버에 붙여 넣기 만하면됩니다. –

답변

0
없음 제가 질문을 이해하지만, 당신이 .html 중에서없이 동일한 URL로 리디렉션 .html 중에서 끝나는 무엇을 원하는 경우,이 트릭을해야 할 경우 완전히 확인은

:

RewriteRule ^/(.*)\.html$ /$1 [R=301,L] 
+0

나는 이것을 시도하고 [http : /www.pavlinaplus.com/podcast/growth.html] to [http://www.pavlinaplus.com/growth] – Jeremy

+0

^앞에 그것을 잊어 버렸습니다. 다시 시도하십시오! –

+0

여전히 불행히도 작동하지 않습니다. 실제로 pavlinaplus.com/podcast/growth가 pavlinaplus.com/growth로 리디렉션되도록 현재 상황이 발생했습니다. (pavlinaplus.com/podcast/growth.html도 여전히 작동 함) – Jeremy

0

이 방법을이다 html에서 non-html로만 전환 할 수 있습니다.

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ (/[^\ ]+)\.html\ [NC] 
RewriteRule^%1 [L,R=301]