Making WordPress 2.0 run on IIS

Perform the following changes:

1. Change REQUEST_URI in wp-settings.php and add PATH_INFO (Will make WP-cache work on IIS): if ( empty( $_SERVER['REQUEST_URI'] ) ) { $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; 2. Change wpdb in wp_db.php and modify this (Make sure all MySQL tables are using UTF8): mysql_query("SET NAMES 'utf8'"); $this->select($dbname); } 3. Change get_archives in template_functions_general.php: } elseif ('yearly' == $type) { $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit); if ($arcresults) { $afterafter = $after; foreach ($arcresults as $arcresult) { $url = get_year_link($arcresult->year); if ($show_post_count) { $text = sprintf('%d', $arcresult->year); $after = ' ('.$arcresult->posts.')' . $afterafter; } else { $text = sprintf('%d', $arcresult->year); } echo get_archives_link($url, $text, $format, $before, $after); } } } 4. Updated Classes.php so the search can handle quoted search: // If a search pattern is specified, load the posts that match if (!empty($q['s'])) { // added slashes screw with quote grouping when done early, so done later $q['s'] = stripslashes($q['s']); if ($q['sentence']) { $q['search_terms'] = array($q['s']); } else { preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q[s], $matches); $q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]); } $n = ($q['exact']) ? '' : '%'; $searchand = ''; foreach((array)$q['search_terms'] as $term) { $term = addslashes_gpc($term); $search .= "{$searchand}((post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}'))"; $searchand = ' AND '; } $term = addslashes_gpc($q['s']); if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] ) $search .= " OR (post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')"; $search = " AND ({$search}) "; } 5. Installed the plugin Atom 1.0 for WordPress and changed it so it would allow different feeds and work with IIS: <link rel="self" type="application/atom+xml" href="<?php echo get_bloginfo_rss('rss2_url'); ?>atom/" /> global $feed; if (is_feed() && $feed=="atom") { 6. Added a httpd.ini with the following contents: [ISAPI_Rewrite] # Rules to ensure that normal content gets through RewriteRule /software-files/(.*) /software-files/$1 [L] RewriteRule /images/(.*) /images/$1 [L] RewriteRule /favicon.ico /favicon.ico [L] RewriteRule /robots.txt /robots.txt [L] # For file-based wordpress content (i.e. theme), admin, etc. RewriteRule /wp-(.*) /wp-$1 [L] # Rules to perform 301 redirect (Remove index.php if already specified) RewriteRule /index.php/(.*) /$1 [I,RP] # For normal wordpress content, via index.php RewriteRule ^/$ /index.php [L] RewriteRule /(.*) /index.php/$1 [L] 7. Added a Robots.txt with the following contents: User-agent: * Crawl-delay:30 Disallow: /wp-content/ Disallow: /wp-includes/ Disallow: /wp-admin/ Disallow: /xmlrpc.php Disallow: /wp-trackback.php Disallow: /wp-settings.php Disallow: /wp-rss2.php Disallow: /wp-rss.php Disallow: /wp-register.php Disallow: /wp-rdf.php Disallow: /wp-mail.php Disallow: /wp-pass.php Disallow: /wp-login.php Disallow: /wp-links-opml.php Disallow: /wp-feed.php Disallow: /wp-config.php Disallow: /wp-commentsrss2.php Disallow: /wp-comments-post.php Disallow: /wp-blog-header.php Disallow: /wp-atom.php Disallow: /wp-commentsatom.php Disallow: */feed Disallow: */atom Disallow: */rss2 Disallow: */rss Disallow: */trackback

Updated: 27 September 2007

Tags:
Category:

Leave a Reply

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