wordpress 3.1 on iis6 – redirect hell

I’ve been having a nightmare setting up wordpress 3.1 on iis6

So here are my notes

I’m using IIRF with the following set up

RewriteLog c:\temp\iirf
RewriteLogLevel 3
MaxMatchCount 1
RewriteEngine On
IterationLimit 4
StatusInquiry ON
# Do not pass to wordpress if the file or directory exists
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^/wp-(.*)$ - [L,I]
RewriteRule ^/$ - [L,I]
RewriteRule ^/(.*(js|ico|gif|jpg|png|flv|swf|css))$ /$1 [L,I,U]
RewriteRule ^/(?!wp-[^\?\/]*)([^\?]+)$ /index.php [L,I,U]

This works fine, for all pages apart from the homepage (anyone more fluent in regex’s is welcome to assist me if I could have been cleverer).

To stop the homepage going in an infinite loop redirecting to itself, I have installed this plug in http://wordpress.org/extend/plugins/permalink-fix-disable-canonical-redirects-pack/

…and then, since I’m not using query strings in my permalinks, I edited it as follows:
add_action('init', 'requesturipow_init');
function requesturipow_init() {
  {
   // --- thirzah fix since don't want q's
   // if(isset($_REQUEST['q'])) {
   // $_SERVER['REQUEST_URI'] = "/" . $_REQUEST["q"];
 
   if(isset($_SERVER["HTTP_X_REWRITE_URL"])) {
   $_SERVER['REQUEST_URI'] = "/" . $_SERVER["HTTP_X_REWRITE_URL"];
   // --- end of thirzah fix
  }else{
  if (empty($_SERVER['QUERY_STRING'])) {
  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
      } else {
  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . "?" .
  $_SERVER['QUERY_STRING'];
      }
    }
  }
}
remove_filter('template_redirect', 'redirect_canonical');
 

This entry was posted in Misc. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>