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