I have an application, it can be accessed in a browser through server's IP address followed by the port number or through server's name followed again the by port number. So currently this two options are:
The application can also be accessed through HTTPS in similar manner (HTTPS + port for HTTPS):
I would like to make a redirection in Apache 2.4 which will redirect all above mentioned sites to one working on HTTPS:
Below are some examples how this redirect should work.
So, I need to cut out the port number, take everything beyond it and add it to app.mydomain.net, and also redirect every possible way of getting to my app to https://app.mydomain.net.
Could you please help me resolve this problem? In the configuration file I was able to create simple HTTP to HTTPS redirection using VirutalHosts, which redirect from for example http://app.mydomain.net to https://app.mydomain.net:
<VirtualHost *:80>
ServerName app.mydomain.net
Redirect permanent / https://app.mydomain.net/
</VirtualHost>
<VirtualHost *:443>
ServerName app.mydomain.net
SSLEngine On
# etc...
</VirtualHost>
I also tried with below commands, but they doesn't work for me. I have properly SSL configured and mod_rewrite enabled in Apache configuration.
<VirtualHost *:80>
ServerName app.mydomain.net
RewriteEngine On
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName app.mydomain.net
SSLEngine On
# etc...
</VirtualHost>