本文介绍了如何使用htaccess的重定向HTML扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 目前,这两个环节中表现出同样的页面: http://www.example.com/podcast/episode.html http://www.example.com/podcast/episode 我想要做的是重定向所有的HTML类型的链接到非HTML链接什么。我知道这看起来简单,做htaccess的,但它不是为我工作。下面是我的htaccess code到目前为止: RewriteEngine叙述上    的RewriteBase /    #removing斜杠    的RewriteCond%{} REQUEST_FILENAME!-d    重写规则^(。*)/ $ $ 1 [R = 301,L]    #non WWW到www    的RewriteCond%{HTTP_HOST}!^ WWW \。    (。*)重写规则^ $ HTTP://www.% {HTTP_HOST} / $ 1 [R = 301,L]    #shtml    将AddType text / html的的.html    的AddHandler服务器解析的.html    #html    的RewriteCond%{} REQUEST_FILENAME!-f    的RewriteCond%{} REQUEST_FILENAME!-d    重写规则^([^ \。] +)$ $ 1.HTML [NC,L]    #index重定向    的RewriteCond%{THE_REQUEST} ^ [AZ] {3,9} \ /指数\ html的\ HTTP /    重写规则^指数\ html的$ http://example.com/ [R = 301,L] 解决方案 的RewriteCond%{THE_REQUEST} \ html的重写规则^(。*)\。HTML / $ 1 [R = 301,L] At the moment, both of these links show the same page:http://www.example.com/podcast/episode.htmlhttp://www.example.com/podcast/episodeWhat I want to do is redirect all the html-type links to the non-html links.I know this might seem simple to do with htaccess, but it's not working for me.Here's my htaccess code so far: 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] 解决方案 RewriteCond %{THE_REQUEST} \.htmlRewriteRule ^(.*)\.html$ /$1 [R=301,L] 这篇关于如何使用htaccess的重定向HTML扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-27 15:28