0

I have a website say example.com and want to redirect everything from http to https. Also I have additional requirement of redirecting http://example.com (and https://example.com) to https://example.com/Portal/loginpage. In addition, I have many applications that need to be accessible at URLs like https://example.com/app1, /app2, /support etc that should not be redirected to https://example.com/Portal/loginpage.

OS is CentOS 7. Apache/2.4.6 . I put the following entries in apache virtualhost file (80 and 443 ports). Both virtual host configs are in separate files.

RewriteEngine On

RedirectMatch ^/$ https://example.com/Portal/loginPage

As per the above set rule, only / should get redirected, not /app1, /app2 or /support.

Now the main redirection http://example.com to https Portal/loginpage is working fine. Even /app1 , /app2 are accessible in respective URLs without redirecting to Portal loginpage. But somehow https://example.com/support is getting redirected to Portal/loginpage. Tried various methods of redirections after following some online tutorials. None of them resolved the issue, infact some solutions created redirect loop and broken the main website also. Please help.

  • Why do you think Apache is doing the redirects? It may be your application. – Michael Hampton Jun 14 '20 at 18:28
  • This website is behind haproxy and application is deployed in two servers. I can access the support application with IP/application. Only when I try to access with example.com/support it is redirecting to example.com/Portal/loginpage. – Sajeesh Jun 15 '20 at 03:23
  • That doesn't explain why it isn't your application sending the redirects! – Michael Hampton Jun 15 '20 at 03:29
  • Before adding the above mentioned RedirectMatch entries in virtual host, application was accessible. That is why I suspect this is an apache issue. – Sajeesh Jun 15 '20 at 03:46
  • Finally got it working. The application had some functionality that redirects to login page in http. We added an entry in haproxy config to redirect http to https and then it started working. Thanks Michael for guiding to correct path. – Sajeesh Jun 18 '20 at 03:12

0 Answers0