In continuation to the one of the first posts in this blog Nicely structured wordpress permalinks on IIS 6 for subdirectory blog location I need to add something.
I was setting up a blog for a friend and encountered an error in the code, which I’ve added for Everest Computers Blog. This simply forced me to figure out what the code does and find the solution, which I did.
Here’s the new wp-404-redirect.php code:
<?php
$qs = $_SERVER['QUERY_STRING'];
$pos = strrpos($qs, ‘:’);
$restOfStr = substr($qs, $pos);$pos = strpos($restOfStr, ‘/’);
$path = substr($restOfStr, $pos);//$path=’/2009/01/test-post-only/’;
//echo “path (should be with year): $path”;
$_SERVER['REQUEST_URI'] = $path;
$_SERVER['PATH_INFO'] = $path;include(’index.php’);
?>
The trick is to make sure that the value of $path equals to the exact custom link value i.e. it should start from “/”, then a year should go, then “/”, then a month and so on exactly copying the custom link. In this case everything works.
A little bit of the code explanation: after the URL, path usually contains “:80/”. The code finds it and then looks for the first “/” and then retrieves $path from here.




