Server-Side Redirect in PHP
Tuesday, April 15, 2008

Took me long enough to find this.  One thing that I found somewhat frustrating about PHP was the inability to do a server-side redirect.  Well, apparently, you can.  Here is the code:

<?php
header("location:http://www.carolingianrealm.info/");
?>

I found this tip on CodingForums.com.

Relative URLs are permitted, as are query string parameters.

The advantage of this technique over an include/return statement is that the new URL is reflected in the browser's location bar.

I've updated my Wander link accordingly.

Leave a comment

Good philosophy must exist, if for no other reason, because bad philosophy needs to be answered.
— C.S. Lewis
The Weight of Glory and Other Addresses