[wp-hackers] Rewrite URIs Hack

Seamus Leahy leahy at au.org
Mon Nov 20 15:29:03 GMT 2006


First off, I have used WordPress for a while now but I am fairly new to the
hacking of it.

I am in the process of moving a blog over to WordPress and would like to use
some custom mod_rewrites to prevent breaking old links while being able to
move to a more logic URI scheme. Since I have not found an answer for how to
get WordPress 2 to handle custom rewrites, I worked on a little hack in
wp-settings.php. 

wp-settings.php:
...
if ( ! isset($blog_id) )    $blog_id = 1; // START HACK // Fix for rewritten
URIS with mod rewrite if(!empty($_SERVER["REDIRECT_QUERY_STRING"]) &&
!empty($_SERVER["REDIRECT_URL"]) && $_SERVER["REDIRECT_URL"] ==
"/index.php"){    $_SERVER['REQUEST_URI'] = "/index.php"; } // END HACK //
Fix for IIS, which doesn't set REQUEST_URI if ( empty(
$_SERVER['REQUEST_URI'] ) ) {
...

One thing that I know could cause issues is if WordPress is installed in a
different directory other than the root.  In addition, from my test
REDIRCT_QUERY_STRING is reflected in QUERY_STRING; but will this always be
the case?


Seamus.



More information about the wp-hackers mailing list