How to redirect URL in Glassfish / Payara Java EE server
In the admin panel, navigate to :
Configuration, HTTP Service, Virtual Servers, server
Scroll to bottom of page :
Add Property
Name :
redirect_goyun.info
( for the name, it should be "redirect_****", ie, always start with "redirect_", and then you can append other characters)
Value :
from=/{name of webapp to redirect} url={URL to redirect traffic to}
For example :
from=/myApp url=http://www.goyun.info
Click ‘Save’ button.
You can do:
from=/myApp/myPath url=http://www.goyun.info/myPath2
too.
And request parameters are redirected too.
The above only redirects to a specific address, to redirect with subfolder, for example:
/myApp/myPah1 to http://it.goyun.info/myPath1
/myApp/myPath2 to http://it.goyun.info/myPath2
then use url-prefix instead:
from=/myApp url-prefix=http://www.goyun.info
This redirect only works for HTTP method GET, it doesn't work for HTTP method POST.
Directly in domain.xml:
For url-prefix,
Configuration, HTTP Service, Virtual Servers, server
Scroll to bottom of page :
Add Property
Name :
redirect_goyun.info
( for the name, it should be "redirect_****", ie, always start with "redirect_", and then you can append other characters)
Value :
from=/{name of webapp to redirect} url={URL to redirect traffic to}
For example :
from=/myApp url=http://www.goyun.info
Click ‘Save’ button.
You can do:
from=/myApp/myPath url=http://www.goyun.info/myPath2
too.
And request parameters are redirected too.
The above only redirects to a specific address, to redirect with subfolder, for example:
/myApp/myPah1 to http://it.goyun.info/myPath1
/myApp/myPath2 to http://it.goyun.info/myPath2
then use url-prefix instead:
from=/myApp url-prefix=http://www.goyun.info
This redirect only works for HTTP method GET, it doesn't work for HTTP method POST.
Directly in domain.xml:
<virtual-server hosts="${com.sun.aas.hostName}" http-listeners="http-listener-1,http-listener-2" id="server" log-file="${com.sun.aas.instanceRoot}/logs/server.log" state="on">
<property name="docroot" value="${com.sun.aas.instanceRoot}/docroot"/>
<property name="accesslog" value="${com.sun.aas.instanceRoot}/logs/access"/>
<property name="sso-enabled" value="false"/>
<property name="allowLinking" value="true"/>
<property name="redirect_i" value="from=/goyun.info/ca.html url=https://goyun.info"/>
</virtual-server>
For url-prefix,
<property name="redirect_i" value="from=/goyun.info url-prefix=http://it.goyun.info"/>
will redirect http://current-host/goyun.info?id=88 to http://it.goyun.info/goyun.info/?id=88
<property name="redirect_i" value="from=/goyun.info/ url-prefix=http://it.goyun.info/i88"/>
will correctly redirect http://current-host/goyun.info?id=88 to http://it.goyun.info/goyun.info?id=88
Comments
Post a Comment