As promised in the previous post, here’s what you need to do to get clean URLs for WP in IIS.

  1. Create a new PHP file wp-404-handler.php in the root folder (in case you are not sure, this is the folder that has “wp-admin”, “wp-content”, “wp-includes” sub folders and bunch of other php files ) and copy paste the following code in it.<?php
    $qs = $_SERVER['QUERY_STRING'];
    $pos = strrpos($qs, ‘://’);
    $pos = strpos($qs, ‘/’, $pos + 4);
    $_SERVER['REQUEST_URI'] = substr($qs, $pos);
    $_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
    include(’index.php’);
    ?>
  2. Open IIS manager – Expand local computer – Expand Web Sites – Right click on your site – Click Properties – Click Custom Errors tab – Select 404. (See image below)IIS Website Custom errors tab
  3. Click Edit – Set Message Type to “URL” and URL to “/” (See image below)404 edit properties
  4. Click OK.
  5. Now login to your WordPress admin control panel. Click Settings and click Permalink (wp-admin/options-permalink.php)
  6. Select “Custom structure” and set the text to “/%year%/%monthnum%/%day%/%postname%/”
  7. And you are done! Your site should now have clean URLs like this site does.