public static String getLocationUrl(String url) {RequestConfig config = RequestConfig.custom().setConnectTimeout(50000).setConnectionRequestTimeout(10000).setSocketTimeout(50000).setRedirectsEnabled(false).build();//不允许重定向 CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(config).build(); String location = null;int responseCode = 0;HttpResponse response;try {response = httpClient.execute(new HttpGet(url));responseCode = response.getStatusLine().getStatusCode();if (responseCode == 301) {org.apache.http.Header locationHeader = response.getFirstHeader("Location");location = locationHeader.getValue();}} catch (Exception e) {e.printStackTrace();}return location;}