【问题标题】:Redirect permanent string replacement重定向永久字符串替换
【发布时间】:2017-06-15 20:51:27
【问题描述】:

我想要网址:

https://example.com/en/category/post+name_tour123456

指向:

https://example.com/en/category/post+name+123456

我要删除_tour

我可以使用 .htaccess 吗?

我创建了一个正则表达式来匹配所有这些链接:

((http[s]?):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([^_]+(?=_)*)(\W?_tour?)([0-9]*)

谢谢

【问题讨论】:

    标签: .htaccess url url-rewriting url-redirection http-status-code-301


    【解决方案1】:

    所以你可以只匹配请求。试试这个规则,看看它是如何工作的。

    RewriteEngine on
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /en/category/(.+)\+(.+)\+_tour(.*) [NC]
    RewriteRule ^ /en/category/%1+%2+%3 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2018-06-04
      • 1970-01-01
      • 2012-08-26
      • 1970-01-01
      • 1970-01-01
      • 2019-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多