Redirect webmail.domain.com to mail.domain.com/squirrelmail

Discussion in 'Installation/Configuration' started by breauxlg, Aug 14, 2012.

  1. breauxlg

    breauxlg New Member

    I know this is probably very simple and I'm just not getting it, but I want my users to be able to type in webmail.domain.com and have ispconfig3 redirect to mail.domain.com/squirrelmail. I love squirrelmail, but I've had to answer one too many questions about the name. I can do the cname pointing, but don't know how to make Ispconfig3 handle it.
     
  2. tahunasky

    tahunasky Member

    For CentOS 6.3 what i have done, is when a user types in mail.domain.com (or mail.domain1.com, mail.domain2.com etc) it goes to roundcube, but can be the same for squirrelmail.

    Create a DNS mail CNAME record for each domain you want to redirect the subdomain mail to squirrelmail. I think ispconfig automatically makes an A record for mail, but if you are going to the same IP address i prefer the CNAME as if i change the IP address i dont need to change every subdomains records IP address, just the main domain A record..

    SO in DNS create the CNAME record.

    Code:
        
    CNAME 	mail 	domain.com.
    
    then create a file as below:

    /etc/httpd/conf/sites-available/_default.vhost
    Code:
      
    <VirtualHost *:80>
        ServerName mail.domain.com
        ServerAlias mail.*
        DocumentRoot /usr/lib/squirrelmail
        ServerAdmin [email][email protected][/email]
    # put the below 3 lines if you require SSL connectiom
        RewriteEngine  on
        RewriteCond    %{HTTPS} !=on
        RewriteRule ^mail(.*) https://mail.{HTTP_HOST}
    </VirtualHost>
    
    # the below section is only need if you have above 3 lines and want SSL
    <VirtualHost *:443>
        ServerName mail.domain.com
        ServerAlias mail.*
        ServerAdmin [email][email protected][/email]
        DocumentRoot /usr/lib/squirrelmail
        
        SSLEngine On
        SSLCertificateFile /usr/local/ispconfig/interface/ssl/ispserver.crt
        SSLCertificateKeyFile /usr/local/ispconfig/interface/ssl/ispserver.key
     </VirtualHost>
    
    
    then i create a link to the /etc/httpd/conf/sites-enabled/ directory:

    Code:
    ln -s /etc/httpd/conf/sites-available/_default.vhost /etc/httpd/conf/sites-enabled/000-default.vhost
    
    this way it doesnt matter what domain is used, if the put in the mail subdomain they will all go to the same place, and any new domains you add with the mail subdomain will also be sent to squirrelmail without any extra configuring.
     
    Last edited: Aug 15, 2012
  3. fbartels

    fbartels New Member

    The cheapest trick probably would be to put this php file into the directory of webmail.domain.com. This way your customer will be automatically redirected to http://mail.domain.com/squirrelmail

    Code:
    <?php
    header("Status: 301 Moved Permanently");
    header("Location:http://mail.domain.com/squirrelmail");
    exit;
    ?>
    
    
     
    Last edited: Aug 15, 2012
  4. Sir Henry

    Sir Henry Member

    I think he does not even want his users to know where the redirection goes to.

    With ISPConfig this issue is as simple as creating a site domain.com and a subdomain mail.domain.com with a proper redirect. If the real files are outside the web directory you could solve this with a symbolic link. You will then also have to add the real path to the PHP open_basedir in the Options tab.
     
  5. breauxlg

    breauxlg New Member

    Now squirrelmail doesn't even come up

    Now, when I goto squirrelmail, I get this box that pops up:
    You have chosen to open

    which is a: application/x-httpd-suphp (671 bytes)
    from:www.domainname.com

    What should Firefox do with this file?
     
  6. fbartels

    fbartels New Member

    you have been presented three different ways to achieve what you want. Which way have you chosen?
     
  7. tahunasky

    tahunasky Member

    It could be an error from rewriting the address... What have you done ?

    I would try this in the squirrelmail.conf or what ever other file you have used with the alias:

    Code:
    
    Alias /webmail /opt/squirrelmail
    Alias /sm /opt/squirrelmail
    
    <Directory /opt/squirrelmail>
      [B]Options +FollowSymLinks[/B]
      Order allow,deny
      allow from all
    
      RewriteEngine  on
      RewriteCond    %{HTTPS} !=on
      RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    </Directory>
    
     
  8. Sir Henry

    Sir Henry Member

    You have to enable suPHP for the directory, see this article for a similar issue.
     

Share This Page