title: Perform 301 redirect from http to https in Apache Tomcat
body: <p>I have configured SSL in my web application. I have installed the certificate in my Tomcat as per the required steps. </p>
  
  <p>The tutorial that I have been following is
  <a href="https://www.mulesoft.com/tcat/tomcat-security" rel="noreferrer">https://www.mulesoft.com/tcat/tomcat-security</a></p>
  
  <p>I have enforced the use of https over http which means that any request to http will be forwarded to https. I made the following changes in my server.xml</p>
  
  <pre><code>&lt;Connector port="8080" protocol="HTTP/1.1" 
  
             connectionTimeout="20000" 
  
             redirectPort="443"
  
             proxyHost="10.1.1.1" proxyPort="80"
  
             URIEncoding="UTF-8"
  
             maxHttpHeaderSize="32768"/&gt;
  </code></pre>
  
  <ul>
  <li>See more at: <a href="https://www.mulesoft.com/tcat/tomcat-security#sthash.6zIVA27x.dpuf" rel="noreferrer">https://www.mulesoft.com/tcat/tomcat-security#sthash.6zIVA27x.dpuf</a></li>
  </ul>
  
  <p>The web.xml changes are as follows:</p>
  
  <pre><code>&lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;SecureConnection&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
      &lt;user-data-constraint&gt;
          &lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt;
      &lt;/user-data-constraint&gt;
  &lt;/security-constraint&gt;
  </code></pre>
  
  <p>However, the redirect that is taking place is temporary re-direct ie 302. 
  I want to use 301 re-direct ie., permanent redirect.</p>
  
  <p>How can I achieve that?</p>