title: How to stop sendRedirect and encodeRedirectURL from converting URL from https to http
body: <p>I have 3 different server environments, out of them in one of the server environments the following line in the code is mysteriously converting &quot;HTTPS&quot; Download URL to &quot;HTTP&quot; on redirection</p>
  <pre><code>response.sendRedirect(response.encodeRedirectURL(publicationURL));
  </code></pre>
  <p>Here is the complete function which use this line</p>
  <pre><code> @RequestMapping(value = {&quot;exampleUrlPath&quot;,&quot;exampleUrlPath&quot;})
  
      public ModelAndView downloadDocument(final HttpServletRequest request, final HttpServletResponse response,
              @PathVariable String reportId) throws IOException {
          ModelAndView modelAndView = null;
          final String publicationID = request.getParameter(&quot;publicationId&quot;);
          String publicationURL = retrieveFacade.getPublicationURL(publicationID);
          publicationURL = publicationURL.replaceAll(&quot;\&quot;&quot;, &quot;&quot;);
          if (null != publicationURL) {
  
             // publication URL is HTTPS here as per the logs... 
  
             response.sendRedirect(response.encodeRedirectURL(publicationURL));
          }
          return modelAndView;
      }
  </code></pre>
  <p>the strange thing is that it is only happening in one of the environments and not on the other two servers. All three servers are using HTTPS.</p>
  <p>Because of this conversion, my download is not happening due to the &quot;mixed content&quot; issue.</p>
  <p>What type of configuration I should check to overcome this issue. (conf file, htaccess file etc)</p>
  <p>Server info: Apache Wildfly</p>
  <p>Host: AWS</p>
  <p>found these questions little connected with my issue.</p>
  <p><a href="https://stackoverflow.com/questions/18891210/how-to-reproduce-sendredirect-issue-https-change-to-http">How to Reproduce sendRedirect issue - HTTPS change to HTTP</a></p>
  <p><a href="https://stackoverflow.com/questions/27542488/how-to-redirect-to-https-on-tomcat-behind-elb">How to redirect to https on tomcat behind ELB</a></p>