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

Finally, brethren,
whatever is true,
whatever is noble,
whatever is right and just,
whatever is pure,
whatever is lovely,
whatever is admirable —
if anything is excellent or praiseworthy —
fix your mind on these things.
— Philippians 4:8