0

Let's say my app is www.example.com.

When I put mydomin.com in the browser, it should redirect to https://www.example.com.

I have configured SSL already on my server.

If I put https://www.example.com, it always opens, but it does not redirect if I entered example.com.

Here is my connector:

<Connector port="8080" connectionTimeout="20000" protocol="org.apache.coyote.http11.Http11NioProtocol" redirectPort="443" />

<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol"               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"               clientAuth="false" sslProtocol="TLS" keystoreFile="file.jks" keystorePass="pass" />

My server is Tomcat 7 and Linux box.

Grant Miller
  • 27,532
  • 16
  • 147
  • 165
user1061865
  • 181
  • 1
  • 6
  • Do you enter example.com:8080 or just example.com when you expect the redirect? The http default port is 80. – andi Sep 08 '18 at 07:30
  • I just entered example.com that's it. – user1061865 Sep 08 '18 at 08:26
  • Do I need to redirect the 80 port also to 443 through connector?? – user1061865 Sep 08 '18 at 08:26
  • 1
    yes, you have to redirect port 80 to 443, the default port in http is 80, so if you want to redirect all requests to https you have to add new connector. – Arash Khajelou Sep 08 '18 at 10:46
  • Maybe you just want to redirect all HTTP traffic to HTTPS ? If so, it's in your application web.xml to configure a security constraint, look at this [answer](https://stackoverflow.com/a/22534392/7748072) – Eugène Adell Sep 08 '18 at 12:35

1 Answers1

1

your http port is 8080 instead of the default 80. A url without the port number will default to port 80 hence http://www.example.com. would go to http://www.example.com:80/.

  • You are right king but after redirecting the 80 to 443 also I am still able to access my application over http by typing http://example.com/appname/user/login.htm – user1061865 Sep 08 '18 at 18:46
  • I should not open page under http as i have already redirected 80 to 443 but it is still doing :-( – user1061865 Sep 08 '18 at 18:47
  • This answer seems to be incomplete. Have a look into the link Eugène Adell has posted in his comment. – andi Sep 10 '18 at 08:28