HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   General (http://www.howtoforge.com/forums/forumdisplay.php?f=15)
-   -   www redirect? (http://www.howtoforge.com/forums/showthread.php?t=25911)

commentator 10th August 2008 12:30

www redirect?
 
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?

till 11th August 2008 11:15

add www.domain2.com as co-domain to the website www.domain.com

commentator 11th August 2008 17:40

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

falko 12th August 2008 20:14

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

commentator 12th August 2008 20:40

Code:

<VirtualHost <myip>:80>
ServerName www.domain2.com:80
ServerAdmin webmaster@domain2.com
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"

falko 13th August 2008 17:58

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]


commentator 13th August 2008 22:07

thanks, thats working

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

till 13th August 2008 22:12

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.


All times are GMT +2. The time now is 12:07.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.