Redirecting subdomain to a different website

Discussion in 'General' started by briand0713, Mar 22, 2013.

  1. briand0713

    briand0713 New Member


    I am having problems trying to figure out how to redirect a subdomain to a different website.

    Here's what I want to do:
    Redirect: (hosted by me) -> (hosted by a different service)

    Everytime I setup/edit the 'Subdomain for website' and test it, just directs to

    I'm hoping someone could help me set this up. Thanks
  2. falko

    falko Super Moderator ISPConfig Developer

    What's your ISPConfig version? Do you use Apache or nginx?
  3. briand0713

    briand0713 New Member

    ISPConfig v3 and I use Apache
  4. Jepso

    Jepso New Member

    Here is how I did something similar:

    Instead of adding subdomain I added A-record to DNS.
    When users tries to access DNS points to specific IP where redirects are handled. Behind this IP there is a index.php where I read what site was requested and check from "redirects_db_table" if there is a row for this site. If row for this site was found, I have two ways for redirecting; URL and URL Frame -redirect. Desired method is stored in the same db row. If predefined method is URL, browser will be redirected to with header('Location: '.$result["target"]);. With URL Frame an iframe is created and target site or url is loaded into it like this: <iframe src="<?= $result["target"]; ?>"></iframe>. In both cases $result["target"] is the
  5. Jepso

    Jepso New Member

    You could also create a CNAME record for
    Type: CNAME
    Name: forum
    Priority: 0

    I think you can also use .htaccess file to do the redirect (not sure if this works):
    //Rewrite to forum
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST}[nc]
    RewriteRule (.*)$1 [r=301,nc,l]

    But if you still want to do this by adding subdomain, I guess you could do it like this:
    Host: forum
    Redirect Type: L
    Redirect Path: /forumredir/

    Now you can create forumredir folder to web directory and create index.php which contains header('Location:');
  6. briand0713

    briand0713 New Member

    I've tried editting the CNAME to direct to the redirect site ( but it still didn't work.

Share This Page