Redirecting in PHP
Moderator: General Moderators
Redirecting in PHP
My Question is
I have a domain name and what I wanna be able to do is. ... have users go to X.Domain.com and then have that redirect to domain.com/users/X
Can someone tell me how to do this?
x.domain.com -> domain.com/users/x
y.domain.com -> domain.com/users/y
Please reply
I have a domain name and what I wanna be able to do is. ... have users go to X.Domain.com and then have that redirect to domain.com/users/X
Can someone tell me how to do this?
x.domain.com -> domain.com/users/x
y.domain.com -> domain.com/users/y
Please reply
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Code: Select all
header('location: http://www.domain2.com/somedir');But i'd go with PHP example given above...it just makes life easier
Last edited by alex.barylski on Thu Jun 22, 2006 11:45 am, edited 1 time in total.
I don't know if this will work or not, it's just some code I threw together from the php manual...
Code: Select all
$CurrentAddress = strtolower(strtok($_SERVER['SERVER_PROTOCOL'], '/')).'://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
switch($CurrentAddress) {
case 'http://x.thisaddress.com':
header("Location: http://www.domain1.com");
exit();
break;
case 'http://y.thataddress.com':
header("Location: http://www.domain2.com");
exit();
break;
default:
header("Location: http://www.domain1.com");
exit();
}- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
What was in your .htaccess file? Just putting a .htaccess file up shouldn't screw anything up unless what was in the .htaccess was not correct.dirgeshp wrote:how can i check to see if i can?
if so, what would i have to do...
i tried placing a script in the .htaccess file...but it screwed up everything
so i guess i might not be able to