Page 1 of 1

simple PHP question for those who know ASP.NET/C#

Posted: Fri Sep 25, 2009 4:52 am
by ColdCold
Hello all,

I know very little PHP and I just need some quick help on a simple script. I just want to transfer a request to another page based on the host name of the incoming request. In ASP.NET, one could use

Code: Select all

Response.Redirect("newpage.aspx");
however I would like to avoid a "302 Found" redirect for SEO reasons. Therefore, in ASP.NET I would use

Code: Select all

Server.Transfer("newpage.aspx");
which returns a "200 OK" response with the new page.

Would someone be so kind as to show me how to do this in PHP? Something equivalent to this:

Code: Select all

protected void Page_Init(object sender, EventArgs e)
{
    string host = Request.Url.Host;
    string newpage;
    if (host == "localhost")
        newpage = "sub1/pg1.aspx";
    else if (host == "www.myhost.com" || host == "myhost.com")
        newpage = "sub2/pg1.aspx";
    else if (host == "www.anotherhost.com" || host == "anotherhost.com")
        newpage = "sub3/pg1.aspx";
    else
        newpage = "sub4/pg1.aspx";
    Server.Transfer(newpage);
}
Thank you!!

-ColdCold

Re: simple PHP question for those who know ASP.NET/C#

Posted: Sat Sep 26, 2009 12:13 pm
by Mirge