2012-07-04 16 views
5

Obecnie oba te linki pokazują tę samą stronę:Jak przekierować rozszerzenie html za pomocą htaccess?

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

Co chcę zrobić jest przekierować wszystkie linki html-Type do linków non-html.

Wiem, że to może wydawać się proste w przypadku htaccess, ale to nie działa dla mnie.

Oto mój kod .htaccess tak daleko:

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

możliwe duplikat [Usuwanie duplikatów (rozszerzenie html vs non-html)] (http://stackoverflow.com/questions/11301039/removing -duplicate-copies-html-extension-vs-html) –

Odpowiedz

9
RewriteCond %{THE_REQUEST} \.html 
RewriteRule ^(.*)\.html$ /$1 [R=301,L] 
+1

Działa doskonale. Dziękuję Gerben. – Jeremy

Powiązane problemy