7

現時点では、これらのリンクは両方とも同じページを表示しています。

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

私がやりたいことは、すべての html タイプのリンクを非 html リンクにリダイレクトすることです。

これは htaccess で行うのが簡単に思えるかもしれませんが、私にとってはうまくいきません。

これまでの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]
4

1 に答える 1

19
RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
于 2012-07-04T20:52:06.487 に答える