【问题标题】:How can I do a 301 redirect from http to https in Wildfly 8.2?如何在 Wildfly 8.2 中进行从 http 到 https 的 301 重定向?
【发布时间】:2016-01-04 20:42:32
【问题描述】:

我的 web.xml 具有以下安全约束:

<security-constraint> 
    <web-resource-collection>     
        <web-resource-name>App</web-resource-name> 
        <url-pattern>/*</url-pattern>
    </web-resource-collection> 
    <user-data-constraint> 
        <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
</security-constraint>

此配置通过 302 重定向将所有 http URL 重定向到 https。除了通过 Wildfly 8.2 中的 301 重定向之外,有没有其他方法可以完成相同的操作?

【问题讨论】:

  • 我唯一能想到的就是编辑 undertow 本身....不过不知道该怎么做。
  • 您确实需要自定义ServletExtension。我现在不能从头顶告诉实现细节。
  • @BalusC,我来看看这种方法。如果你能找到时间提供一个例子,我将不胜感激。在那之前,我会继续阅读。
  • 你在此期间找到了这个问题的答案吗@k170 ?
  • @Thermometer,不幸的是仍然没有答案。如果我找到了,我一定会发布的。

标签: jakarta-ee redirect seo wildfly


【解决方案1】:

我能想到的一种方法是在undertow 中使用基于谓词的处理程序。请参阅以下链接中的示例:

https://http2.undertow.io/documentation/core/predicates-attributes-handlers.html

该示例解释了基于请求路径的可配置 302 响应。我认为您可以对其进行调整以返回 301。

【讨论】:

  • 这真的适用于 j_security_check 吗?我不这么认为。还是你自己试过?
猜你喜欢
  • 2016-07-02
  • 2015-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多