删除重复的副本(HTML扩展VS非HTML) [英] Removing duplicate copies (html extension vs non-html)

查看:142
本文介绍了删除重复的副本(HTML扩展VS非HTML)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法让第一个URL重定向到第二个URL?

Is there any way to have the first URL redirect to the second URL?

http://www.example.com/podcast/episode.html < BR> http://www.example.com/podcast/episode

有没有办法强制.html扩展重定向到URL的非HTML版本,以免显示为同一页的重复副本。

Is there any way to force the .html extension to redirect to the non-html version of the URL, so as not to show up as duplicate copies of the same page.

我的htaccess code,此刻是:

My htaccess code at the moment is:

    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]

这可能吗?

推荐答案

不完全肯定,如果我理解这个问题,但是如果你想要的东西在.html结尾重定向到相同的URL没有html的,这应该做的绝招:

Not entirely sure if I understand the question, but if you want anything ending in .html to redirect to the same URL without the .html, this should do the trick:

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

这篇关于删除重复的副本(HTML扩展VS非HTML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆