Redirect /webmail to webmail.example.com

Discussion in 'Tips/Tricks/Mods' started by Th0m, Feb 11, 2021.

Thread Status:
Not open for further replies.
  1. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    To redirect example.com/webmail to webmail.example.com, follow these steps:
    On the webserver, create a config file for Apache:
    Code:
    nano /etc/apache2/conf-available/roundcube-redir.conf
    and put this in there:
    Code:
    Redirect /webmail https://webmail.example.com
    Then enable the config:
    Code:
    a2enconf roundcube-redir
    and reload Apache2
    Code:
    systemctl reload apache2
    Now, if you go to example.com/webmail, you will be redirected to webmail.example.com (with a 302 redirect).


    Replace example.com with your own domain :)
     
    Last edited: Mar 1, 2021
    jz_, Gaston Girardi and ibrahim-ROM like this.
  2. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    For nginx:
    Code:
    rewrite ^(/webmail/)(.*)$ http://webmail.example.com/$2 permanent;
     
  3. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    I suggest changing this to
    Code:
    rewrite ^/webmail$ https://webmail.example.com redirect;
    for the following reasons:
    - Temporary redirect instead of permanent - in case your client moves to a different hosting company
    - Redirect to https instead of http
    - Redirect /webmail instead of /webmail/
     
    ahrasis likes this.
  4. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    To create the site "webmail.example.com":
    - Create DNS record for webmail.example.com
    - Create site webmail.example.com, enable Let's Encrypt, disable auto subdomain
    - Under the tab "Options", add this to Apache directives:
    Code:
    DocumentRoot "/var/lib/roundcube/public_html"
    Alias "/stats" "{DOCROOT}/stats"
     
    Last edited: Aug 18, 2021
    nhybgtvfr, atle and Jesse Norell like this.
Thread Status:
Not open for further replies.

Share This Page