From last post, I choose WordPress because it works properly on both Linux and Windows. However, after installed it on IIS Windows Server 2003, I could access the admin portal (Dashboard) but when I went to the homepage, I got this error message in few seconds: “The page isn’t redirecting properly”
It’s so strange because I’ve installed WordPress so many times on both Windows and Linux, but in this morning, I installed the latest version of WordPress (3.1.1) and the issue “Redirecting Loop” occurred. It’s not a problem with the current server as it run properly with the previous version and with the latest version, I can access the Dashboard.
I googled a lot I found an article on WordPress Support: http://wordpress.org/support/topic/windows-server-infinite-redirect-after-upgrading-to-31/page/3 that help me fix the issue.
Basically, we need to make some changes in the redirect_canonical() function in the wp-includes/canonical.php file.
The original redirect_canonical() function content:
[php] function redirect_canonical( $requested_url = null, $do_redirect = true ) {global $wp_rewrite, $is_iis7, $wp_query, $wpdb;
if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_iis7 && !iis7_supports_permalinks() ) )
return;
if ( !$requested_url ) {
// build the URL in the address bar
$requested_url = is_ssl() ? ‘https://’ : ‘http://’;
$requested_url .= $_SERVER[‘HTTP_HOST’];
$requested_url .= $_SERVER[‘REQUEST_URI’];
}
.
.
.
.
[/php]
Need to be changed likes below:
[php highlight=”7.8,9,10″] function redirect_canonical( $requested_url = null, $do_redirect = true ) {/*global $wp_rewrite, $is_iis7, $wp_query, $wpdb;
if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_iis7 && !iis7_supports_permalinks() ) )
return;*/
global $wp_rewrite, $is_IIS, $is_iis7, $wp_query, $wpdb;
if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) )
return;
if ( !$requested_url ) {
// build the URL in the address bar
$requested_url = is_ssl() ? ‘https://’ : ‘http://’;
$requested_url .= $_SERVER[‘HTTP_HOST’];
$requested_url .= $_SERVER[‘REQUEST_URI’];
}
$original = @parse_url($requested_url);
if ( false === $original )
return;
.
.
.
.
[/php]
Note: if you upgrade your WordPress to a new version in the future, the file will be overwritten, so please keep in mind to check & update again.