PDA

View Full Version : Page redirection from a subdomain



John
12-11-2002, 12:07 PM
I'm having some trouble redirecting a client from a subdomain to the main domain. Here is the script I am using:



<?php



session_start();

$_SESSION["name"] = 'This is a redirection from '.$_SERVER["HTTP_HOST"];

header("Location: http://www.appointit.com");

exit;

?>



I get a "page not found" error when this script is run. And yet, when I enter the URL above directly into the browser I get the page that I am trying to redirect to.

I may not understand HOW a subdomain works, and need some help with it.

Any advice would be greately appreciated (especially if it works! :D)

John

dbmasters
12-12-2002, 11:39 AM
try this:


<?php

ob_start();

session_start();

$_SESSION["name"]="This is a redirection from ".$_SERVER["HTTP_HOST"];

ob_end_clean();

header("Location: http://www.appointit.com");

ob_end_flush();

?>

What's with the session thing? Is that really necessary?

John
12-12-2002, 03:18 PM
Thanks, but I'm afraid it's a moot point now, as I wanted to create subdomains on the fly. Unfortunately the setup, as it is now, will not allow that.

The session variable was a value to be passed back to the index page to customize that page for the client who has his business name as the subdomain.

Anyway, if you would like to read about what I was trying to accomplish go here:

http://sitepointforums.com/showthread.php?...&threadid=87550 (http://sitepointforums.com/showthread.php?s=&threadid=87550)

eugene
12-17-2002, 08:52 PM
You may want to try URL rewriting using .htaccess.

John
12-17-2002, 09:15 PM
Thanks, Eugene.

Do you know of any tutorials that explain this process?

John

tstern
12-18-2002, 02:46 AM
John-
See this thread:
http://www.hostpc.com/phpbb/viewtopic.php?t=6

It explains how to use .htaccess to link to Squirrelmail. Obviously, if you wanted to redirect to another site, you could just substitute that site's address for the squirrelmail address in that tutorial.

Best,
TS