ISPConfig alias domain not redirecting to main domain

Discussion in 'General' started by lonerunner, Feb 26, 2015.

  1. lonerunner

    lonerunner Member

    I have domain `mydomain.net` and now i managed to grab another name for it `mydomain.com`, but as my main domain works very well i just want to redirect the second domain i got to my first one. Well as i know alias domain is for that right ?

    So i set dns in my registrar to point to my server, than in ISPConfig i go to sites and `Add new Aliasdomain to website~

    Aliasdomain : mydomain.com
    Parent website : mydomain.net
    Redirect : none
    Auto subdomain : *. <-all

    Than i go to my dns settings and add record for alias domain. I tried first without an dns settings and it fails to load, than i just added a record for mydomain.com that points to ip and ns address of my server.

    But somehow it seems to fail and all i get is :

    It works!

    This is the default web page for this server.

    The web server software is running but no content has been added, yet.

    This is an message like i added new domain record not an alias. Everything seems to works fine on the server. Going to mydomain.net loads a website, but mydomain.com loads the message above.
     
  2. vhacker11

    vhacker11 Member

    Try changing the redirect type to permanant. You can also do similar thing by using CNAME record.
     
  3. lonerunner

    lonerunner Member

    It still not working, i tried changing and i also tried recreating everything from start, i also tried messing up with some dns settings and nope.

    I just took a look at the apache vhost file now and i see that there is some type of redirect inside.

    The apache makes in /etc/apache2/sites-available the vhost file for every site on the server and there is mydomain.net.vhost file. Inside that file there are some indications of alias domain.

    ServerName mydomain.net
    ServerAlias www.mydomain.net
    ServerAlias *.mydomain.com mydomain.com
    ServerAdmin [email protected]

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mydomain\.net$ [NC]
    RewriteRule ^(.*)$ http://www.mydomain.net$1 [R=301,L]
    RewriteCond %{HTTP_HOST} ^(mydomain\.com|((?:\w+(?:-\w+)*\.)*)((?!www\.)\w+(?:-\w+)*)(\.mydomain\.com))$ [NC]
    RewriteRule ^(.*)$ http://www.mydomain.com$1 [R=301,L]​
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    your .com domain is a server alis of the .net vhost, so you should see the content of the .net vhost and not a it works page. It woks get only shown when apache cant find a matching vhost. Please check that the .com domain points to the same IP address then the .net domain in dns as apache will not use this vhost when the IP address differs.
     
  5. lonerunner

    lonerunner Member

    I found where the problem is finally.

    In /etc/apache2/ there are 2 folders /sites-enabled and /sites-available. Well normally /sites-enabled should contain the .vhost files but only a symlinks to real .vhost files whose are in /sites-available folder. For some reason only the file to this domain was not a symlink, it was actual .vhost file with data. And since changing ispconfig settings, change the files inside /sites-available this is why it didn't worked.

    So i made .bkp of .vhost file inside /sites-enabled and created symlink to file inside /sites-available. And now it works. :)
     
    Last edited: Mar 26, 2015
    Popcorn006 and till like this.

Share This Page