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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

location = Please Help 1

Status
Not open for further replies.

chuckbridges

Programmer
Apr 15, 2005
19
US
I have programmed a lot in Java Script
there is a location = command you can use to re-direct
the page to another page...

Is there a way in PHP to excute a line of code that loads
another whole page replacing the existing one?

Thanks A million
 
Not really. When you receive the page, php, which runs on the server, is done and connection is lost. PHP cannot do anything until user (or JavaScript) requests another (or same) page from the server again. However, PHP has the ability to redirect, the only catch is, that page must be redirected before any output is sent to browser. So, if you want to display a page then redirect, use meta tags or javascript. If you just want to evaluate some code (and send no output) and then redirect, use PHP:
Code:
header("Location: [URL unfurl="true"]http://www.newurl.com");[/URL]
 
If the page is puclic viewable, you need to specify that it's permanently moved.
If you fail to do so, google and other search-engines will punish your page-ranking!

Code:
header("HTTP/1.1 301 Moved Permanently"); // fix for google
header("Location: [URL unfurl="true"]http://domain.tld/");[/URL] 
header("Connection: close");  // fix for IE

If you use the meta-refresh, a low countdown will also be punished!

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top