【问题标题】:htaccess using url patternhtaccess 使用 url 模式
【发布时间】:2016-10-31 11:20:25
【问题描述】:

这是一个关于使用 htaccess 进行 301 重定向的非常基本的问题,但我对 regexp 和 htaccess 的技能非常有限或根本没有技能。

我想将所有不带点 html 的 url 查询重定向到 .html 我的意思是如何将所有somethinghtml 重定向到something.html,请注意something 是每个网址中的真实单词。 any-somethinghtmlany-something.html some-somethinghtmlsome-something.html - another-somethinghtmlanother-something.html

等等……

【问题讨论】:

  • 你有没有尝试过?网络上有大量的重写教程,包括 StackOverflow。只为你做这项工作是不公平的。首先查看 RewriteRule。也许谷歌搜索“mod rewrite url 301”

标签: apache .htaccess url redirect


【解决方案1】:

试试:

RewriteEngine on


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

这会将/foohtml 永久重定向到/foo.html

【讨论】:

    猜你喜欢
    • 2014-09-03
    • 2012-10-03
    • 2016-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-12
    • 2017-01-30
    • 2015-04-03
    相关资源
    最近更新 更多