【问题标题】:mod-rewrite rule - How do I cut a URL after the characters ":"mod-rewrite 规则 - 如何在字符“:”之后剪切 URL
【发布时间】:2016-06-24 20:02:04
【问题描述】:

我想在modrewrite 的帮助下清理我的网址。 以便谷歌可以更好地阅读它们。

所以 URL 现在看起来: domain.com/article:::451.html

所以它应该看起来像: domain.com/article

我从不使用 modrewrite。有人可以帮我吗?

【问题讨论】:

    标签: mod-rewrite


    【解决方案1】:

    重定向:

    domain.com/article:::451.html

    domain.com/article

    您可以使用以下规则:

    RewriteEngine on
    
    
    RewriteCond %{THE_REQUEST} /article:::451\.html [NC]
    RewriteRule ^ /article [L,R]
    

    如果旧的uri是动态的,例如:(/foo:::1234.html),你可以使用:

    RewriteEngine on
    
    
    RewriteCond %{THE_REQUEST} /([^:]+):::[0-9]+\.html [NC]
    RewriteRule ^ /%1 [L,R]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-16
      • 2011-07-20
      • 1970-01-01
      • 2015-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-13
      相关资源
      最近更新 更多