after searching and try-and-erroring for a while I came to the conclusion that my problem is a bit too special for google :-)
I have 2 domains and multiple subs
example.org
- cloud.example.org
- wiki.example.org
- *.example.org (all other to this domain) should redirect to example.org which shows the "under construction" image.
beispiel.de
- blog.beispiel.de
- same here: *.beispiel.de should redirect to beispiel.de
I have 1 file per subdomain with 1 vHost in my Apache conf.
I use "Let's encrypt" for https.
Problems:
http://blupp.example.com goes to https://blupp.example.com and Firefox shows the connection not secure warning. After klicking Ignore, it redirects to the main page but with https://blupp.example.com in the URL.
-> Error It should go to example.com
Another Problem is:
example.com is my first page. So if sth. goes wrong at beispiel.de, it redirects to the first page: cloud.example.com
-> Error I dont want to mix example.com and beispiel.de, but only want to rent one server :-)
These are my files (order is important, I know :-)
0_redirects.conf
Just make http requests -> https
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule "/" https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
1_cloud-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin@...
ServerName cloud.example.com
ServerAlias cloud.example.com
<Directory /var/www/example.com/cloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory>
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
Same for wiki.example.com and blog.beispiel.de, each with an incremented prefix number.
I first tried to get all example.com pages running, so I left beispiel.de untouched.
Now I tried many ways to create an additional vHost for both main domains that redirects evrything else to the correct main example or beispiel, but failed.
I tried to redirect
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName null
ServerAlias *.example.com
Redirect permanent / example.com
</VirtualHost>
</IfModule>
and set this config on a higher order position (100).
I don't know what to do here.
Can someone help?
Best regards
Eddi