【问题标题】:ee: redirect url with trailing forward slashee:使用尾部正斜杠重定向 url
【发布时间】:2014-09-26 15:29:52
【问题描述】:

如果有人向表达式引擎中的 url 添加尾部正斜杠,我如何重定向到正确的页面?

例如: A) www.acme.com/event - 是正确的网址

B) www.acme.com/event/ - 内容相同

问题是我使用 Disqus 作为评论系统,它将两者解释为不同的页面。因此,简单的解决方案是在出现斜杠时重定向到 url A。

{if segment_2=="event/"}
 {redirect="/event"}
{/if}

这似乎不起作用。任何不涉及.htaccess 的想法?它只适用于一页。

谢谢。

【问题讨论】:

  • 看起来 URL 无关紧要。唯一标识该页面的是disqus_url 的值。您应该能够可靠地设置它。 help.disqus.com/customer/portal/articles/…
  • 很棒的电话!你是绝对正确的。问题解决了。

标签: redirect expressionengine


【解决方案1】:

重写我的评论作为答案...

看起来 URL 无关紧要。唯一标识该页面的是disqus_url 的值。您应该能够可靠地设置它。

来自documentation...

disqus_url

告诉 Disqus 服务当前页面的 URL。如果未定义, Disqus 将使用 window.location.href。此 URL 用于查找 如果 disqus_identifier 未定义,则创建一个线程。此外, 此 URL 在创建线程时始终保存,以便 Disqus 知道线程属于哪个页面。

虽然 window.location.href 在没有 disqus_url 的情况下使用,但我们 强烈建议定义此变量。如果用户访问您的页面 URL http://example.com/helloworld.html?123, Disqus 实际上可能 加载与用户来自不同的线程 http://example.com/helloworld.html.

为确保始终显示正确的线程,您应该定义 在您的页面上,使用绝对 URL,var disqus_url = 'http://example.com/helloworld.html';

【讨论】:

    猜你喜欢
    • 2011-09-13
    • 2016-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-07
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    相关资源
    最近更新 更多