使用单独的SSL证书时,将子域重定向到不同的路径

时间:2015-03-28 18:01:41

标签: apache ssl dns vhosts

我有一个包含多个不同子域的网站,并且希望网站的某些部分具有比其他网站更高的安全级别。如管理区域。我知道您可以根据需要创建任意数量的证书。我遇到的问题是,无论首先列出哪个子域,它的DocumentRoot都会应用于重定向到https://的所有其他子域。这是httpd-vhosts.conf中的代码:

    # HTTP Configuration
    <VirtualHost *:80>
    ServerName account.example.com
    RewriteEngine On
          RewriteCond %{HTTPS} !=on
          RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
          DocumentRoot "/Applications/MAMP/htdocs/Website/Account"
    </VirtualHost>

    # SSL Configuration
    <VirtualHost *:443>
        ServerName account.example.com
        SSLEngine on
        SSLCertificateFile /Applications/MAMP/conf/apache/account.crt
        SSLCertificateKeyFile /Applications/MAMP/conf/apache/account.key
        DocumentRoot "/Applications/MAMP/htdocs/Website/Account"
    </VirtualHost>

    #Secure Admin Config
    <VirtualHost *:80>
    ServerName secure.example.com
    DocumentRoot "/Applications/MAMP/htdocs/Website/Secure"
RewriteEngine On
          RewriteCond %{HTTPS} !=on
          RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
          DocumentRoot "/Applications/MAMP/htdocs/Website/Secure"
    # Other directives here

    </VirtualHost>
    #SSL Config for Admin area

    # SSL Configuration
        <VirtualHost *:443>
            ServerName secure.example.com
            SSLEngine on
            SSLCertificateFile /Applications/MAMP/conf/apache/secure.crt
            SSLCertificateKeyFile /Applications/MAMP/conf/apache/secure.key
            DocumentRoot "/Applications/MAMP/htdocs/Website/Secure"
        </VirtualHost>

例如,如果我要转到secure.example.comDocumentRoot/Applications/MAMP/htdocs/Website/Account而不是/Applications/MAMP/htdocs/Website/Secure

有没有办法解决这个问题?

提前谢谢!

0 个答案:

没有答案