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=25)
-   -   Redirecting subdomain to a different website (http://www.howtoforge.com/forums/showthread.php?t=61076)

briand0713 22nd March 2013 06:47

Redirecting subdomain to a different website
 
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

falko 23rd March 2013 18:49

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

briand0713 24th March 2013 18:24

Quote:

Originally Posted by falko (Post 294575)
What's your ISPConfig version? Do you use Apache or nginx?

ISPConfig v3 and I use Apache

Jepso 25th March 2013 10:14

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.

Jepso 25th March 2013 13:27

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');

briand0713 3rd April 2013 06:39

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


All times are GMT +2. The time now is 00:17.

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