'Struts2 - Best way to redirect to another domain
My website has a section that will be migrated to another domain, but all our clients still use the old url, which will be deprecated soon.
What i want to achieve is send 301 moved permanently HTTP Response, and send the users to the new domain.
Already tried
sendRedirect
ServletActionContext.getResponse().setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
ServletActionContext.getResponse().sendRedirect(urlToNewDomain);
and
ServletActionContext.getResponse().setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
ServletActionContext.getResponse().setHeader("Location", urlToNewDomain);
ServletActionContext.getResponse().setHeader("Connection", "close");
and with struts response (using XML)
<result name="externalRedirect" type="httpheader">
<param name="status">301</param>
<param name="headers.location">${targetUrl}</param>
</result>
The response its a 301 like: myDomain.com/newDomainUrl
So it keeps using myDomain.com ... i don't know how t explicitly redirect to a different domain.
Which is the best way to redirect to a different domain?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
