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

In our mail server there are multiple virtual email domain hosted. User can use (this is the first apache virtualhost) to check mail or they can use If the put apache shows the as it is the first virtualhost and doesn't exist. Recently we imposed https for and added this mod_rewrite rule:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

But now users not getting the default webmail page as they were getting before. How can we redirect all request coming to the URL "" to ""? I've tried the following but it didn't work:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (mail.*)

Thanks for your help in advance.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Try this:

NameVirtualHost *:80    
<VirtualHost *:80>   
RewriteEngine On   
RewriteCond %{HTTP_HOST} ^mail. [NC]   
RewriteRule ^(.*)$$1 [L,R=301]    
share|improve this answer
Thanks a lot Tom! It worked!! Thanks again. – Saif Mar 23 '12 at 21:58

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.