2017-04-26 59 views
0

我有一个SAAS,我需要动态创建多个子域(注意:有很多子域,我不知道哪些子域会自动生成)。所以我不能每个重复这一点:SSL通配符Apache

<VirtualHost *:80> 
    ServerName a1.app.example.com 
    Redirect/https://a1.app.example.com 
</VirtualHost> 

有没有办法将http中的每个子域重定向到https ?.像 “重定向/ HTTPS://*.app.example.com” 一些

<VirtualHost *:80> 
    ServerName app.example.com 
    Redirect/https://*.app.example.com 
</VirtualHost> 

<VirtualHost *:80> 
    ServerName app.example.com 
    ServerAlias *.app.example.com 
    DirectoryIndex index.php 
    DocumentRoot /var/www/xxxxxxx 

    SSLEngine on 
    SSLCertificateFile /etc/ssl/xxxxx.crt 
    SSLCertificateKeyFile /etc/ssl/xxxx.key 
    SSLCertificateChainFile /etc/ssl/xxxx.crt 
</VirtualHost> 
+0

您对我提供的答案没有提供任何输入。轻轻提醒你给一些反馈/投票/接受,如果有帮助:-) – Capsule

回答

0

加入,为您的虚拟主机为主:

Options +FollowSymLinks -MultiViews 
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,QSA,R=301] 

并确保mod_rewrite处于活动状态。您可以使用a2enmod rewrite命令激活它。