How can I do a 301 redirect from http to https in Wildfly 8.2?

一世执手 提交于 2019-12-23 23:51:42

问题


My web.xml has the following security constraint:

<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>

This configuration redirects all http URLs to https via 302 redirects. Is there a way to accomplish the same except via 301 redirects in Wildfly 8.2?


回答1:


One way I can think of is using Predicates based handlers in undertow. See the example in the link below:

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

The example explains a configurable 302 response based on request path. I think you can tweak it to return 301.



来源:https://stackoverflow.com/questions/32995244/how-can-i-do-a-301-redirect-from-http-to-https-in-wildfly-8-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!