mod_rewrite not working for subdomain in Apache2

Posted by Matt on Server Fault See other posts from Server Fault or by Matt
Published on 2011-01-08T21:00:04Z Indexed on 2011/01/08 21:55 UTC
Read the original article Hit count: 250

Filed under:

Hi,

I'm having some trouble with mod_rewrite. So I'm implementing it through .htaccess, and I can get it working on my main vhost, domain.com - what I want it to do is rewrite http:// domain.com to force it to https:// domain.com, which it does well. I want to have name-based vhosts for the one IP with the following redirects:

(I'm breaking up domain names with a space because otherwise serverfault recognises them as links)

http:// domain.com --> https:// domain.com http:// staging.domain.com --> https:// staging.domain.com http:// test.domain.com --> https:// test.domain.com http:// beta.domain.com --> https:// beta.domain.com

domain.com redirects to https:// domain.com, but staging.domain.com doesn't, although I can access https:// staging.domain.com. The .htaccess is identical for both, just with the domain name different. It doesn't seem to do any rewriting at all for staging.domain.com, I've tested this by trying to get it to rewrite to www.google.com.

I have a wildcard DNS record, *.domain.com which points to the domain IP.

Is there a particular way I should have the virtualhosts configured to allow this?

I keep reading in the Apache documentation that it doesn't support multiple SSL name-based vhosts. But I can access both https:// domain.com and https:// staging.domain.com just fine.

Any thoughts? Thanks to everyone for your help with this.

© Server Fault or respective owner

Related posts about apache