Rewrite rule: webmail.domain.com to domain.com/webmail

Discussion in 'Installation/Configuration' started by florix.net, Jan 12, 2011.

  1. florix.net

    florix.net Member

    Hi ..

    I am trying to redirect ...

    http://webmail.domain.com/ to http://domain.com/webmail/

    I have written following rewrite code inside one domain vhost file in /etc/httpd/conf/sites-enabled directory, but it is not working ... as ideas?

    rewriteEngine on
    rewriteLog "/var/log/httpd/rewrite_log"
    rewriteLogLevel 9


    RewriteCond %{HTTP_HOST} ^webmail.dsvtrust.org$
    RewriteRule ^(.*)$ http://dsvtrust.org/webmail/ [R=301,L]
     
  2. falko

    falko Super Moderator ISPConfig Developer

    Are there any errors in /var/log/httpd/rewrite_log or in Apache's error log?
     
  3. florix.net

    florix.net Member

    Just above the line

    Include /etc/httpd/conf/sites-enabled/

    I added following lines ..

    <VirtualHost *:80>
    ServerAlias webmail.*
    RewriteEngine On
    RewriteLog "/var/log/httpd/rewrite.log"
    RewriteLogLevel 3
    RewriteCond %{HTTP_HOST} ^webmail\.(.+) [NC]
    RewriteRule (.*) http://%1/webmail/ [R=301,L]
    </VirtualHost>
     
  4. falko

    falko Super Moderator ISPConfig Developer

    Is it working now?
     

Share This Page