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?
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"
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]
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.