Bonjour, alors voilà, j'ai un serveur web avec apache2 et j'ai deux sites que je voudrais rediriger sur la bonne pages. Voici ce que je veux faire en schéma pour que ce soit plus compréhensible.

mondomaine.fr/site1 ----------> https://mondomaine.fr/site1
site1.mondomaine.fr ----------> https://mondomaine.fr/site1
https://site1.mondomaine.fr --> https://mondomaine.fr/site1

mondomaine.fr/site2 ----------> https://mondomaine.fr/site2
site2.mondomaine.fr ----------> https://mondomaine.fr/site2
https://site2.mondomaine.fr --> https://mondomaine.fr/site2

https://mondomaine.fr --> https://mondomaine.fr/site1
mondomaine.fr ---------> https://mondomaine.fr/site1

J'utilise un virtualhost avec pour chaque site un port 80 et un port 443, un peu comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<VirtualHost *:80>
        ServerName site1.mondomaine.fr
        ServerAlias *.site1.mondomaine.fr mondomaine.fr/site1
 
        RewriteEngine On
        RewriteCond %{REQUEST_URI} !^/site1$
        RewriteRule ^(.*)$ <a href="https://mondomaine.fr/site1" target="_blank">https://mondomaine.fr/site1</a> [R=301,L]
        Redirect / <a href="https://mondomaine.fr/site1" target="_blank">https://mondomaine.fr/site1</a>
</VirtualHost>
 
<VirtualHost *:80>
        ServerName site2.mondomaine.fr
        ServerAlias *.site2.mondomaine.fr mondomaine.fr/site2
 
        RewriteEngine On
        RewriteCond %{REQUEST_URI} !^/site2$
        RewriteRule ^(.*)$ <a href="https://mondomaine.fr/site2" target="_blank">https://mondomaine.fr/site2</a> [R=301,L]
        Redirect / <a href="https://mondomaine.fr/site2" target="_blank">https://mondomaine.fr/site2</a>
</VirtualHost>
 
<VirtualHost *:443>
        ServerName mondomaine.fr/site1
        ServerAlias *.site1.mondomaine.fr
 
        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/moncertif.crt
        SSLCertificateKeyFile /etc/apache2/ssl/moncertif.key
</Virtualhost>
 
<VirtualHost *:443>
        ServerName mondomaine.fr/site2
        ServerAlias *.site2.mondomaine.fr
 
        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/moncertif.crt
        SSLCertificateKeyFile /etc/apache2/ssl/moncertif.key
</Virtualhost>
Le problème est que cela ne fonctionne pas vraiment quand je tape https://mondomaine.fr

Si quelqu'un peut m'apporter une petite solution.
Merci pour votre aide.