Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

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 run Roundcube webmail on my VPS. At the moment, it is only accessible from one virtual server hosted on the server, unless a separate Roundcube installation is created for other virtual servers. I would like to be able to make webmail available from any domain/ virtual server that I host, just by adding /webmail to the end.

I'm sure Apache must allow me to do this - only problem is, I don't know how!

share|improve this question
up vote 2 down vote accepted

It's just a simple 301 redirect. Like so:

RewriteRule http://www.somedomain.com/webmail$     http://www.actualdomain.com/webmail/     [R=301,L]

This goes on the server that has these hosted domains. Then it'll route that traffic to the actual VPS that hosts the webmail client.

By the way, well done in picking Roundcube. I'm using it on my VPS, literally is one of the best webmail clients I've come across!

Another way is to include it in your vhosts file with code similar to this:

<VirtualHost *:80>
    ServerName theirdomain.com/webmail
    ServerAlias www.theirdomain.com/webmail
    DocumentRoot "\where\your\folder\is\"
  <Directory "\where\your\folder\is\">
    IndexOptions +FancyIndexing NameWidth=*
    Options Includes FollowSymLinks Indexes
    AllowOverride All
    Order allow,deny
    Allow from all

I know the .htaccess method would work, I'm not entirely sure if the above vhost code would work as well though as I've never tested it.

share|improve this answer
Thanks - so whereabouts do I put that line? Does it go in the httpd.conf file? Is there not a way to do it automatically, so there's no need to insert the line manually for each new virtual server? And yes - quite like Roundcube! Better than Squirrelmail, anyway. – James Jul 3 '12 at 21:08
You would put that line in to a .htaccess file. There is another way which I've updated the answer to show, you would put that in to your vhosts file. – mickburkejnr Jul 5 '12 at 8:17
Excellent - I think I'll give the second option a shot. Thanks! – James Jul 7 '12 at 23:26
Did what I say work? – mickburkejnr Jul 9 '12 at 9:31
Annoyingly, I've had problems with Cloudflare, so I haven't been able to set any additional domains to try this out! Hopefully they'll iron out shortly and I'll pop back with the outcome of trying out what you mention. – James Jul 12 '12 at 7:58

Put the following into your /etc/apache2/httpd.conf, or wherever user configuration for the main host goes:

Alias /webmail /path/to/your/roundcube

As we put this not into a ... section, it applies to all virtual hosts at the same time. See Apache Alias directive.

Note that it is not possible to use the ServerAlias directive for a solution, as that is for hostnames only, not applicable to directories.

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.