【问题标题】:HTACCESS to Remove /amp/ from the end of a URLHTACCESS 从 URL 的末尾删除 /amp/
【发布时间】:2017-01-19 04:18:37
【问题描述】:

/amp/ 错误地显示在我所有 URL 的末尾。我已经修复了它,但我现在有一个烂摊子。我在搜索中有许多带有 /amp/ 的 url,我需要重定向到从末尾删除 /amp/ 的 url。我将如何使用 .htaccess 执行此操作?

我试过了:

RewriteEngine On
RewriteRule ^(.*)/amp/?$ /$1/ [L,R=301]

而且它似乎不起作用。

【问题讨论】:

  • 你在使用某种框架吗?
  • 你能解释一下吗

标签: .htaccess


【解决方案1】:

如果您使用的是 Apache Web 服务器,您可以使用以下规则将您的所有 AMP 网址重定向到非 AMP 版本。

示例 https://example.com/permalink/amp/https://example.com/permalink/

# Redirect from AMP to non-AMP path
RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteRule ^ %1/ [R=301,L]

我希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多