Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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, - what I want it to do is rewrite to force it to, which it does well. I want to have name-based vhosts for the one IP with the following redirects: --> --> --> --> redirects to, but doesn't, although I can access The .htaccess is identical for both, just with the domain name different. It doesn't seem to do any rewriting at all for, I've tested this by trying to get it to rewrite to

I have a wildcard DNS record, * 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 and just fine.

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

share|improve this question

Do you have an "NameVirtualHost" directive? And are you using them in your vhost configuration?

Besides please take a look at this:

If both SSL domains are running on the same IP, only one encryption (certificate) will be used and "clients will receive certificate mismatch warnings and be vulnerable to man-in-the-middle attacks".

share|improve this answer
yes, I've specified two namevirtualhost directives, !ip:80 and !ip:443. They're both in the default site. With these enabled, URL rewriting doesn't work at all – Matt Jan 8 '11 at 23:59
Ok do you have an "AllowOverride" Setting in your vhost configuration?You could also try to put the stuff from your .htaccess into your "<directory> directive. See – shakalandy Jan 9 '11 at 1:32

RewriteEngine can be enabled both globally and on a per-vhost basis. Even if enabled globally, the options don't carry into vhosts by default. You probably just need to turn it back on in the current vhost. RewriteEngine on (and possibly RewriteOptions inherit, depending upon your configuration) in each vhost.

share|improve this answer

Your Answer


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.