Redirecting subdomain to a different website

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

  1. briand0713

    briand0713 New Member

    Greetings,

    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:
    forum.mydomain.com (hosted by me) -> forum.theirdomain.com (hosted by a different service)

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

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

    falko Super Moderator Howtoforge Staff

    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 forum.mydomain.com 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 forum.theirdomain.com 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 forum.theirdomain.com.
     
  5. Jepso

    Jepso New Member

    You could also create a CNAME record for mydomain.com:
    Type: CNAME
    Name: forum
    Data: forum.theirdomain.com.
    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} forum.mydomain.com[nc]
    RewriteRule (.*) http://forum.theirdomain.com/$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
    Domain: mydomain.com
    Redirect Type: L
    Redirect Path: /forumredir/

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

    briand0713 New Member

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

Share This Page