Subdomain redirection

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
Terl
Forum Newbie
Posts: 1
Joined: Sun Sep 26, 2004 3:04 pm

Subdomain redirection

Post by Terl »

I am using a web server package called 'Lansuite' and it does not support subdomains. By using a dynamic host I have no problems setting up, for example, forum.hostedby.homeip.net, where 'forum' is the sub domain. I have worked out how to grab the url via HTTP_HOST.

Code: Select all

<?php 
$page = $_SERVER['HTTP_HOST'];
$noms[0]="/forum.hostedby.homeip.net/"; 
$allervers[0]="hostedby.homeip.net/subsite-forum";
$noms[1]="/yahoo.hostedby.homeip.net/"; 
$allervers[1]="yahoo.com";
$noms[2]="/bad.and.ugly.hostedby.homeip.net/"; 
$allervers[2]="microsoft.com"; 
$dir=preg_replace($noms, $allervers, $page); 
if (!($page === $dir)) 
  { 
header("Location: http://$dir"); 
      exit; 
  } 
print "The domain name <b>$page</b> isn't valid...please verify syntax and / or address";    
?>
But of course, this then changes the URL in the address bar, is the original address can be retained? or am I out of look.

Any help would be appreciated.
Last edited by Terl on Mon Sep 27, 2004 1:33 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you'll need to look at mod_rewrite I believe.
Post Reply