html - 大规模重定向 xyz.html/to xyz.html

标签 html .htaccess seo permalinks

我有一个简单的 html 网站,其中包含 50 多个 html 页面。从 statistics-script 中,我有时会在 xyz.html/(重定向到 404)而不是 xyz.html 之类的页面上看到用户。我知道一个简单的方法是放置一个 301 重定向但是页面太多了。任何人都可以建议一种方法将所有传入流量重定向到带有正斜杠“/”的链接到没有正斜杠的页面吗? (流量通常来自社交媒体)

like 

abc.html/ to abc.html
xyz.html/ to xyz.html
.
.
.
so on

编辑:

我只想在特定目录而不是整个域上执行此操作。例如仅到 www.example.com/section/

   www.example.com/section/abc.html/ to www.example.com/section/abc.html
   www.example.com/section/xyz.html/ to www.example.com/section/xyz.html

最佳答案

 RewriteRule ^((.+)\.html)/$ http://<your-domain>/$1 [L,R=301]

替换为您的域名(如果需要,还包括文件夹)。 响应基于此处提供的数据 mod_rewrite: remove trailing slash (only one!)

关于html - 大规模重定向 xyz.html/to xyz.html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8666249/

相关文章:

javascript - 背景图像与滚动内容一起移动

javascript - Vuejs : fade out-in transition not working

apache - 我如何强制所有流量到 https?

php - 我的 sef 链接如何使用 .htaccess

ember.js - 使 Ember 应用程序可抓取

javascript - 如何将div的id设置为cookie?

javascript - FadeOut 和 fadeIn 不工作

.htaccess 更改/es/到.es

javascript - 如何使用 url 中的 "#q"重定向 "?q"

parsing - 元描述标签,包括电子邮件