Saturday, October 25, 2014

You are here: Home > SEO Analytics, SEO Tips, Small Business Social Media > 10 Steps to Making WordPress Permalinks Work on Windows IIS 6.0

10 Steps to Making WordPress Permalinks Work on Windows IIS 6.0

by webcoachpete on September 7, 2010

Making WordPress Permalinks Work

If you have been in the SEO industry for any amount of time chances are you have gotten a client who installed wordpress on a shared
Windows IIS 6.0 hosting plan.  Or maybe you are a “do-it-yourselfer” who has his wordpress website or blog on a shared Windows IIS 6.0 hosting plan. Either way, chances are you have no idea how to get the permalinks to work and you are trying everything possible!

Let me save you from countless hours of frustration.   Unfortunately, Windows IIS 6.0 doesn’t support WordPress permalinks ~ period!  The reason is because it doesn’t have the ability to use mod_rewrite. It only works if you install a third-party ISAPI filter.  But because you are on a shared hosting plan, you don’t have access to install ISAPI filters and 99.9% of the time your web host won’t install them for you.   You can search far and wide, but mod_rewrites won’t work.  Editing the root of the Windows (web.config) won’t work!  Etc., etc., etc.  – it won’t work.

Look no further.  I lay before you the 10 steps to making WordPress 3.01 Permalinks ~ WORK on a shared Windows IIS 6.0 hosting plan.  Before you begin the steps ~ please make sure that you meet the necessary prerequisites.

PREREQUISITES:

AFirst – Your domain must be a Windows Shared Server and the IIS version must be 6.0.   

If you are Windows IIS 7.0  You will use Create a New Rewrite Rule.
If you are Windows IIS 6.0, but NOT on a shared server.  You will use ASAPI_Rewrite

If  you don’t know your hosting domain information – you can find it by adding Firefox Domain Details Addon to your Firefox.   After installing this, you can check the IIS / Apache version, and the IP details of your domain, etc. in the status bar of the Firefox.  Or you can check with your Server.   If your server is ixwebhosting.com, servergrid.com or a H-Sphere, Plesk or Hosting Controller ~ chances are good that you are on a Windows Shared Server with IIS 6.0.   Check to make sure!

If you are an Apache web server you will use the mod_rewrite and create an .htaccess file.  Remember: Apache is only for Linux server and it cannot be installed in a Windows server. Apache is to Linux server; like, IIS is to Windows server. 

B. Second – To be safe and assure success, You must be using wordpress 3.01.  I have only used this with WP 3.01.  This also works with WP Thesis  and numerous Thesis Skins.  So if you are using Thesis ~ no worries!  

C.  Finally – I have only tested the below 10 steps with the H-Sphere web hosting automated control panel.  I have not used it with “Hosting Controller” nor “Plesk.”  So whichever web hosting control panel you are using (hosting controller, Plesk, H-Sphere or any of the partial beta control panels),  you must have the ability to change your 404 error page with your web host.

10 STEPS:

1.  Open FTP with (ie: FileZilla or SmartFTP, etc.) and at the base of your Wordpress folder (where your wp-admin, wp-content and wp-includes files are located) Create the file wp-404-handler.php  The name of the file is: wp-404-handler.php

2.  Once the new wp-404-handler.php file is created.  Open it for edit in Notepad or BBEdit.

3.  With the file open for edit in Notepad or BBEdit, Paste the following code into your new file wp-404-handler.php 

<?php
// This is the default file for the site. Usually index.php
$default = 'index.php';

// The name of this file.
// Set this value for the URL in Custom Error Properties of your website in IIS.
// Goto: IIS Manager > Websites > [Site Name] > Properties > Custom Errors >
// 404 & 404;2 & 404;3 > URL (Requires a '/' prefix in IIS).
$thisfile = '404-handler.php';

$_SERVER['ORIG_PATH_TRANSLATED'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_TRANSLATED']);
$_SERVER['SCRIPT_FILENAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_FILENAME']);
$_SERVER['ORIG_PATH_INFO'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_INFO']);
$_SERVER['SCRIPT_NAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_NAME']);
$_SERVER['PHP_SELF'] = str_replace($thisfile, $default, $_SERVER['PHP_SELF']);
$_SERVER['PATH_INFO'] = false;

$qs =& $_SERVER['QUERY_STRING'];
$ru =& $_SERVER['REQUEST_URI'];
$pos = strrpos($qs, '://');
$pos = strpos($qs, '/', $pos + 4);
$_SERVER['URL'] = $ru = substr($qs, $pos);
$qs = trim(stristr($ru, '?'), '?');

// Required for WordPress 2.8+
$_SERVER['HTTP_X_ORIGINAL_URL'] = $ru;

// Fix GET vars
foreach ( $_GET as $var => $val ) {
  if ( substr($var, 0, 3) == '404') {
    if ( strstr($var, '?') ) {
      $newvar = substr($var, strpos($var, '?') + 1);
      $_GET[$newvar] = $val;
    }
    unset($_GET[$var]);
  }
  break;
}
include($default);
?> 

This code was created by John at Ikailo Media Solutions.   This code is robust and fixes a lot of the differences between Apache and IIS.   It fixes values in _SERVER and resolves a problem in _GET.  It works with all WordPress versions 2.8 and later.

4.  Check your pasted code and make sure that the very first characters are  <?php and the very last characters are ?> Remove all spaces, new lines, or other garbage before the opening <?php tag and after the closing ?> tag. Now Save it. 

5. Log into your Web Server Control Panel (ie. H-Sphere, Hosting Control or Plesk) and set your sites 404 page, 404.2 page and 404.3 page to point to the wp-404-handler.php url. Most control panels at web hosts allow you to do this. In the H-Sphere Control Panel click on the “error” link in your web services area, here you can set the path to your custom error page for all errors from 400 all the way to your 500.19 page.

6. If you’ve got the option to select between FILE and URL then choose URL.  If you check “URL”: it will allow you to use scripts (php/ASP) to dynamically generate error pages.A big smile to you.  Enjoy!

7.  Log in to your WP 3.01.  Go to Options -> Permalinks in your WordPress admin page, and click the box next to “Custom, Specify below”

8. Put the following in the Custom Structure: /%postname%/ then click “Save Changes” :: Never, ever put your site url in this permalinks custom structure slot.

9.  After you saved changes in your WP permalinks, open a Web browser and click any one of the permalinks in your WordPress blog. You should see the correct content returned by the Web server for each permalink.

10.  If you use Dynamic Content Gallery or other plugins you may have to change the links to reflect your new permalinks.   Thats it!  You now know how to make WordPress Permalinks work on a IIS 6.0 Shared Windows Server allowing you to use the “pretty permalinks” in the WordPress blog engine.  

Do you need help with Search Engine Optimization or Social Media Marketing?

Image of Web Coach Pete Certification.

If you are a SOLAR Installation Company, REALTOR or Small Business Owner needing help, or looking for a professional Internet presence - I can help.

If you need help with a specific Social Media issue or Search Engine Optimization issue or a complete website, I offer consultation, complete web design, and Search Engine Optimization services.

Get in touch and we can talk about your needs and start the process.

Leave a Comment

Previous post: