【问题标题】:How to Redirect user to oldest published post in case of duplicate post using htacess如果使用 htaccess 重复帖子,如何将用户重定向到最旧的发布帖子
【发布时间】:2019-05-25 06:22:56
【问题描述】:

如果使用 htaccess 重定向的重复帖子,我需要在我最旧的帖子上重定向用户。例如:

在上面的2个网址中,第一个是原始帖子,第二个是重复的。我想要一个 htaccess 重定向规则,将所有登陆包含 -2/ 的 URL 的用户发送到其原始帖子。

【问题讨论】:

  • 在旧文件的顶部放 header("Location:https://example.com/my-first-post-2/"); 不需要 htaccess :-)
  • 我有一个 wordpress 网站,帖子是重复的,就像每个帖子都发布了 2 次,一个是正常的 url,另一个是 -2/ 最后的 url……现在 -2/ 是区分元素。 .. 我希望所有在 url 末尾带有 -2/ 的帖子都重定向到没有 -2/ 的 url/

标签: php wordpress .htaccess


【解决方案1】:

另一种方式:唯一的区别可能是延迟,因为 .htaccess 在 php 文件之前处理,但 I think the delay insignificantly small

放在旧文件的顶部

header("Location:https://example.com/my-first-post-2/"); exit;

不担心流量就不用htaccess

【讨论】:

    猜你喜欢
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-15
    • 1970-01-01
    相关资源
    最近更新 更多