www redirect?

Discussion in 'General' started by commentator, Aug 10, 2008.

  1. commentator

    commentator Member

    Hi,

    I added a domain domain.com

    I want to redirect domain.com and www.domain.com to www.domain2.com

    domain.com I setup the redirect and is working.
    www.domain.com shows me the default welcomepage (no index.html)

    how to fix the www to redirect also?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

  3. commentator

    commentator Member

    well if domain.com was on my server it was no problem. It is hosted somewhere else.
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Canyou post the vhost configuration of that vhost from Vhosts_ispconfig.conf?
     
  5. commentator

    commentator Member

    Code:
    <VirtualHost <myip>:80>
    ServerName www.domain2.com:80
    ServerAdmin [email protected]
    DocumentRoot /var/www/web16/web
    ServerAlias www.domain2.com domain2.com
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    ErrorLog /var/www/web16/log/error.log
    Alias /error/ "/var/www/web16/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web16/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web16/user/$1/web/$3
    RewriteEngine on
    RewriteCond %{HTTP_HOST}   ^domain2\.com [NC]
    RewriteRule ^/(.*)         http://www.domain.com/$1 [L,R]
    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
      RewriteRule .* - [F]
    </IfModule>
    </VirtualHost>
    
    
    I also tried adding a co-domain for host "www" but then I get an error something like "already in use"
     
  6. falko

    falko Super Moderator Howtoforge Staff

    Put this in the Apache Directives field in ISPConfig:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST}   ^www\.domain2\.com [NC]
    RewriteRule ^/(.*)         http://www.domain.com/$1 [L,R]
     
  7. commentator

    commentator Member

    thanks, thats working

    why is it not working by default if I setup a redirect for a domain?
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    It is working fine when you use the default redirect. The only difference is that the domain changes when you use the default redirect function and if you use the rule that falko posted above, the domain in the browser bar dioes not change to the target domain.
     

Share This Page