How to create Pretty WordPress Permalinks on IIS WITHOUT using 404 redirects
March 11, 2010 – 11:45 pm
This is an easy step by step tutorial on how to create Pretty WordPress Permalinks on Internet Information Services (IIS) WITHOUT using 404 redirects.
After many hours and hundreds of web searches later I managed to gather bits of info to finally get Pretty WordPress Permalinks to work perfectly on IIS without using IIS’ 404 redirects. As far as I know (from all the web searches), there is no other article on the web that describes the method I have used. So this is the first tutorial on the web that describes how to create Pretty WordPress Permalinks on Internet Information Services (IIS) WITHOUT using 404 redirects.
During the tutorial, when I refer to paths or files for example “index.php”, do not include the “” apostrophes when typing them in
Let’s get started.
-
- Ionic’s ISAPI Rewrite Filter is like mod_rewrite however it was made as an add-on for IIS. Essentially, this ISAPI Rewrite Filter makes your IIS work as if it has mod_rewrite.
And the best thing about it is that its
small, really cheap (free) and easy to use. - Download Ionic’s ISAPI Rewrite Filter at http://www.codeplex.com/IIRF/Release/ProjectReleases.aspx. Download the file “IonicIsapiRewriter-1.2.12c-bin.zip”
- After downloading the compressed file, extract the files and look for “IsapiRewrite4.dll” and “IsapiRewrite4.ini”. These are the 2 important files for this tutorial. Highlight these files and copy them.
- Paste the files to a new appropriate folder, such as “ISAPI” within your “Inetpub” folder. I created a folder called “ISAPI” and within that another folder for the site name e.g. “c:\wwwroot\ISAPI\wordpress”. Later, if you want to use this filter for other sites you’ll need to put these files in a new separate folder. The appropriate folder must have permissions granted to the appropriate Windows principal
(IUSR_hostname). N.B. Don’t create the folder in the web document tree. (it causes problems with detecting
changes in the ini file). - Open IIS go to Control Panel -> Administrative Tools -> Internet Information Services
- To use the ISAPI filter on your WordPress Web site, select the icon for that Web site, right-click the level (icon) that you selected and Click the
Properties button. - Click the ISAPI Filters tab.
- Click Add.
- Type a name for the ISAPI filter. Eg, “Ionic Rewriter”.
- Click Browse and select the ISAPI filter DLL that you copied in
step 3. - Click OK.
- Restart IIS service.
- Open the file “IsapiRewrite4.ini” in the new folder you created. This if the file we use to create the rewrite rules.
- Select all the text in this file and replace it with the following: RewriteRule ^/wordpress/(?!images)(?!wp-[^\?\/]*)([^\?]+)$ /wordpress/rewrite.php?$1
This
rule assumes that your wordpress web site is in a sub folder names “wordpress” e.g. “http://www.example.com/wordpress”. If your WordPress web site is in the root, remove both “wordpress/” from the rule. - Save the file.
- In the Root of your WordPress web site create a new file named “rewrite.php”
- Open the file and paste the following code into it: <?php
$_SERVER[’PATH_INFO’] = $_SERVER[’QUERY_STRING’];
include(’index.php’);
?>This makes the PATH_INFO variable equal to the query string that has been created by the rewrite filter.
- Save the File and close.
- Log into your WordPress Admin section and update the Permalinks.
- You can now remove “/index.php” and use some like “/%year%/%monthnum%/%day%/%postname%/”
- Ionic’s ISAPI Rewrite Filter is like mod_rewrite however it was made as an add-on for IIS. Essentially, this ISAPI Rewrite Filter makes your IIS work as if it has mod_rewrite.
- Ionic’s ISAPI Rewrite Filter
- Configuring ISAPI Rewrite Filter
- Creating the Rewrite File
- Update WordPress Permalinks
You have just created Pretty WordPress Permalinks without using IIS’ 404 redirect.
If you have found this tutorial useful please link back to it from your site. Use the following code:
<a href=”http://www.7three.com/blog/computers/tips-tricks/pretty-wordpress-permalinks-iis-without-404-22/”>Pretty WordPress Permalinks on IIS WITHOUT using 404 redirects</a>
Related Posts:
- Install WordPress on Windows under IIS – Part 1
- Install WordPress on Windows under IIS – Part 2
- Install WordPress on Windows under IIS – Part 3
