View Full Version : PHP - internal redirect without mod_rewrite

02-26-2004, 02:49 AM
I have blog pages archived by month, and I want to serve the most recent month's page when someone accesses the blog's (virtual) home page. But, I don't want an external redirect. I'm currently using this PHP to solve the issue, but assume there's a more elegant solution?
$fp = @fopen( 'http://muledesign.hoologic.com/hoof/2004/february/', 'r' ) or die( 'Heh.' );
while ( $line = @fgets( $fp, 1024 ) ) {
print $line;
fclose( $fp );
?>I name this page index.php, so it acts as my blog's home page.

Note that the URL to the most recent monthly archive is embedded in the source. The blog software is thus generating this page for me, which is why I don't want to use mod_rewrite. As I have it set up now, I don't need to change anything when a new month arrives. As soon as I post a blog entry in a new month, this page (above) is regenerated to "redirect" to the new monthly archive page.


02-26-2004, 08:52 AM
Not quite sure if this is what you meant but anyway ...

$url = 'http://muledesign.hoologic.com/hoof/' . date( 'Y' ) . '/' . strtolower( date( 'F' ) ) . '/';