Domain alias redirection with PHP?

This is a discussion on "Domain alias redirection with PHP?" within the PHP Forum section. This forum, and the thread "Domain alias redirection with PHP? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 10th, 2005, 03:17
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 25
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tim356
Domain alias redirection with PHP?

I've got 1 domain and 3 alias' pointing to that 1 domain. On the server is a forum and in the forum are several different categories of discussion (funny that).

Anyway, I want the main domain to point to the home page of the forum and the others to point to different categories. So, for example this domain: www.category1.com would be redirected to the category 1 forum url.

Is there a way with PHP that I can find out how the user is getting to the site? Would a referer function work for this? If I can tell that the user typed in www.category1.com and was brought to www.mainforum.com then I could write a script to redirect to category 1 forum. Does that make sense? Any ideas?

I've tried using
PHP: Select all

$ref=($_SERVER['HTTP_REFERER']);
if(
$ref=="http://www.category1.com"){
header("Location: http://www.mainforum.com/forum/category1url");
}
else
{
header("Location: http://www.mainforum.com/forum/");

but that didn't work.
Reply With Quote

  #2 (permalink)  
Old Dec 10th, 2005, 04:15
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Domain alias redirection with PHP?

The HTTP_REFERER is for the previous page - the one from which your user followed a link to get to your site. The HTTP_HOST is the host name through which the current host was contacted.

We have several domains with the same main section and we bring in the following from an include file:
Code: Select all
$host = explode(".",$_SERVER[HTTP_HOST]);
$sitefirst = $host[0];
$sitelast = $host[count($host)-1];
and we're then set up (for example) with "net", "uk" or "com" in $sitelast and with "www", "java" or "ireland" in $sitefirst ... so that we have one set of site files but serve subtley varied content. We even switch content completely on occasions to an alternative page without the need for a messy redirect. From later in our header file:
Code: Select all
$page = explode("/",substr($_SERVER[SCRIPT_NAME],1));
$filename = $page[count($page)-1];
$fullfilename = implode("_",$page);
$alternate = "$_SERVER[DOCUMENT_ROOT]/alternate/$host[0]_$fullfilename";
if (file_exists($alternate)) {
include ($alternate);
exit ();
}
Reply With Quote
  #3 (permalink)  
Old Dec 12th, 2005, 03:26
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 25
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tim356
Re: Domain alias redirection with PHP?

Thanks Grahame, will try that.
Reply With Quote
Reply

Tags
domain, alias, redirection, php

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload redirection Ross PHP Forum 8 Feb 28th, 2007 23:32
redirection that is unnoticable. how? christopher Web Page Design 10 May 20th, 2006 17:23
Not unique table/alias: 'q' Gee Bee Databases 1 Feb 5th, 2006 10:05
redirection problem iamzoli PHP Forum 12 Apr 11th, 2004 08:48


All times are GMT. The time now is 21:34.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43