iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old December 10th, 2005, 12:17 AM   #1
Reputable Member
 
Tim356's Avatar
 

Join Date: Nov 2003
Location: Australia
Age: 27
Posts: 329
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Tim356 will become famous soon enough
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
Code:
$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.
Tim356 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 10th, 2005, 01:15 AM   #2
Reputable Member
 

Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 grahame is a jewel in the rough grahame is a jewel in the rough grahame is a jewel in the rough
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:
$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:
$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 ();
}
grahame is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 12th, 2005, 12:26 AM   #3
Reputable Member
 
Tim356's Avatar
 

Join Date: Nov 2003
Location: Australia
Age: 27
Posts: 329
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Tim356 will become famous soon enough
Re: Domain alias redirection with PHP?

Thanks Grahame, will try that.
Tim356 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
domain , alias , redirection , php


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 8 February 28th, 2007 08:32 PM
redirection that is unnoticable. how? christopher HTML, XHTML and CSS 10 May 20th, 2006 02:23 PM
Not unique table/alias: 'q' Gee Bee Databases 1 February 5th, 2006 07:05 AM
redirection problem iamzoli PHP 12 April 11th, 2004 05:48 AM


Search Engine Optimization by vBSEO 3.2.0 RC8