Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a Wildcard SSL Certificate that is supposed to work on any subdomain of a given domain.

So in this server we have this file structure:

/home/DOMAIN/public_html/subdomainx /home/DOMAIN/public_html/subdomainy etc...

Now, the Certificate is installed, but when you visit any subdomain over https (example: hxxps://subdomainx.domain.com ) it points to

/home/DOMAIN/public_html/index.php

We need that when you visit a subdomain via https hxxps://subdomainx.domain.com

That it points to the the same directory that it's http equivalent: /home/DOMAIN/public_html/subdomainx

Our provider tells us that this is not possible, that the current behaviour is correct, and that to achieve this we need to do it with htaccess.

I've tried a few things, incluiding this solution, that seems to be what I need: http://stackoverflow.com/questions/5365612/advice-on-configuring-htaccess-file-to-redirect-http-subdomain-to-https-equival

But can't get it to work.

Any tips? Thanks.

Added: The server is Apache.

share|improve this question
    
The wildcard SSL in this scenario isn't that important, other than to prevent the browser from complaining. The question you're really asking is how to redirect requests to the proper directory. You'll have to tell us what web server you're using and show us the relevant part of your configuration. –  cjc Apr 3 '12 at 19:51
    
Server is Apache. Right now the .htaccess is empty. I'll try to reproduce what we tried and add it later. –  Ericko Apr 3 '12 at 20:41
1  
In case it isn't obvious, the "relevant parts" cjc is talking about are the vhosts with the ServerName, ServerAlias and DocumentRoot directives in them. All of them. –  Ladadadada Apr 3 '12 at 22:18

2 Answers 2

up vote 0 down vote accepted

Make sure you have the ssl.subdomain.domain.com.conf properly configured in your vhost folder.

This file should look like this:

<VirtualHost *:443>
ServerAlias www.subdomain.domain.com subdomain.domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /home/domain/public_html/subdomain
BytesLog domlogs/domain-bytes_log
ServerName www.domain.com
CustomLog domlogs/domain.com-access_log combined
#ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/

User domain
Group domain

suPHP_ConfigPath /home/domain/etc/

SSLEnable
SSLCertificateFile /opt/apache/conf/ssl.crt/domain.com.crt
SSLCertificateKeyFile /opt/apache/conf/ssl.key/domain.com.key
SSLLogFile /var/log/ssl/domain.com_log
UserDir public_html
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown


. 
.
.

</VirtualHost>
share|improve this answer

I'll bet that you're in need of a NameVirtualHost *:443 (or however your vhosts are defined).

Another option would be to define a VirtualDocumentRoot, if your vhost configs are all identical except for the docroot.

.htaccess files are definitely not required for anything that you can do with Apache - with the exception of "use htaccess files".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.