Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URL Redirect

Status
Not open for further replies.

5thMaster

Technical User
Joined
May 9, 2004
Messages
1
Location
GB
Sorry guys I am new to the forums and I don't seem to be able to find this in the forums.

I am temporarily doing my own hosting and I have edited the host file with the company that holds my domain and created the subdomains i need. The problem is when they get to my site I don't know how to redirect them without modifying apache which I really don't want to do. Can this be done with PHP.

At the moment I have 2 sub domains pointing at the IP address of my server. forums and webmail.
Is there any way of writing a php page using the header command so that if someone requests webmail.mydomain.com it reads the incoming name request and redirects to mydomain.com/webmail or whatever sub domain I set up
Any help would be greatly appreciated :)
 
The $_SERVER superglobal array has an element 'SERVER_NAME' which will contain the hostname to which the browser tried to connect.

Based on that value, you can use the header() function to send the browser to various URLs.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top