Berlin Berlin - 2 months ago 16
Apache Configuration Question

Apache redirect from https

I installed an SSL Certificate on my server, and https works fine.

Http redirect works fine for example

http://login.example.com
->
https://example1.com/index.html


But redirect from https not working, for example
https://login.example.com
->
https://example1.com/index.html
.

its just go to the main page of my server
https://redirect.example.com


Any suggestions on how to get the redirect from https to work?

Thanks !

<VirtualHost *:80>
RewriteEngine On
ServerName redirect.example.com
RewriteCond %{HTTP_HOST} ^login\.example\.com(.*)
RewriteRule (.*) https://example1.com/index.html [L]
</VirtualHost>

<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/httpd/my.crt
SSLCertificateKeyFile /etc/httpd/my.pem
ServerName redirect.mydomain.com

RewriteEngine On
ServerName redirect.example.com
RewriteCond %{HTTP_HOST} ^login\.example\.com(.*)
RewriteRule (.*) https://example1.com/index.html [L]

</VirtualHost>


Thanks!

Answer

Use server alias for your Rewrite Rule:

ServerAlias login.example.com

you can use multiple ServerAlias for multiple Rewrite Rule

Comments