Windows Hosting Blog

The better way to do permalinks in WordPress on Windows

Lately we’ve been blogging about WordPress here at AppliedI.net. The reasons for that are plenty but mostly it’s because many customers have acknowledged that they find it a great tool and have found these articles useful.  As Andre pointed out earlier many people are starting to use blogging tools like wordpress as a full CMS application. 

One of the great features wordpress has is that you can enable a feature called permalinks.  According to Wikipedia:

A permalink is a URL that points to a specific blogging entry even after the entry has passed from the front page into the blog archives. Because a permalink remains unchanged indefinitely, it is less susceptible to link rot.

A permalink is useful as it provides an easy to remember URL to a blog article and is also pretty search engine friendly.

How permalinks used to be done on Windows

Previously if you wanted to enable permalinks in your Windows based blog you had only a couple options:

  1. using a custom 404 redirect as explained on the Keyboard face blog.
  2. using an ISAPI filter, such as Dean Lee’s isapi filter.

These worked well and I’ve used both in blog. But today, thanks to isapi-rewrite 3.0 from helicontech.com we have a new way to do it. Helicontech’s latest version of isapi-rewrite is mod_rewrite compatible. Mod-rewrite is a URL rewriting engine used in apache web servers and since almost all PHP apps are initially written for apache based servers they make use of mod_rewrite rules. Helicontech saw this and rewrote their own isapi-rewrite tool to be mod_rewrite compatible.

This means if you have an application like wordpress that makes use of mod_rewrite you’ll be able to use the same rules and just upload a .htaccess file to your Windows hosted account and you’re done!  It couldn’t be an easier. Fortunately for you, AppliedI.net includes isapi-rewrite 3.0 for free with all shared hosting accounts so you have this functionality immediately.

How to do permalinks in wordpress in IIS6 with your blog in the root folder

Many users put their blog in their web root folder so when you go to http://www.example.com/ the blog comes up immediately. This tutorial portion assumes this is where your blog is. If this isn’t where you’re blog is please read the next section.

Once you’ve installed your wordpress blog on your site you’ll want to log into the admin section and select options and then select permalinks. You’re going to make the following changes:

1. Under Common Options:

Select Custom, specify below. Enter the custom structure as: /archives/%year%/%monthnum%/%day%/%postname%/

image thumb The better way to do permalinks in Wordpress on Windows

2. Under Optional:

We’re going to enter a category base and tag base. This is important because you’re going to categorize your articles (to make them easier for the visitors to browse) and tag your articles to help with searches and also allow your related articles to be grouped. For Category base: /category/ For Tag base: /tags/

image thumb 3 The better way to do permalinks in Wordpress on Windows

3. Update Permalink Structure

Once these are set you’re going to click the button, update permalink structure. This is going to update these settings your database. We’re not done though. We still have to upload the .htaccess file. 

4. Create .htaccess file

You’ll create a new text file and name it .htaccess. In this text file you’re going to include the text:

# Helicon ISAPI_Rewrite configuration file
# Version 3.0.0.21

# BEGIN WordPress
# <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# </IfModule>
# END WordPress

You’re going to want to enter the text just like that and then upload this file to your website’s root folder. That’s it! Permalinks should now work.

How to setup wordpress permalinks for /blog/ on IIS6 (or windows hosting)

The steps in this section of the tutorial are just like the steps above except this assumes your blog is in a subfolder called /blog/ so your blog is accessed as: http://www.example.com/blog/. If your blog is in a subfolder other than blog you’d change the instructions below substituting your folder name for /blog/. The only step that changes is step #4.

Once you’ve installed your wordpress blog on your site you’ll want to log into the admin section and select options and then select permalinks. You’re going to make the following changes:

1. Under Common Options:

Select Custom, specify below. Enter the custom structure as: /archives/%year%/%monthnum%/%day%/%postname%/

image thumb The better way to do permalinks in Wordpress on Windows

2. Under Optional:

We’re going to enter a category base and tag base. This is important because you’re going to categorize your articles (to make them easier for the visitors to browse) and tag your articles to help with searches and also allow your related articles to be grouped. For Category base: /category/ For Tag base: /tags/

image thumb 3 The better way to do permalinks in Wordpress on Windows

3. Update Permalink Structure

Once these are set you’re going to click the button, update permalink structure. This is going to update these settings your database. We’re not done though. We still have to upload the .htaccess file. 

4. Create .htaccess file

You’ll create a new text file and name it .htaccess. In this text file you’re going to include the text:

# Helicon ISAPI_Rewrite configuration file
# Version 3.0.0.21

# BEGIN WordPress
# <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
# </IfModule>
# END WordPress

You’ll notice RewriteBase has now changed to reflect the /blog/ folder instead of /.  That’s because we’re assuming your blog is in a subfolder named /blog/. Once you’ve modified this file, save it and then upload it into the subfolder /blog/ where your blog is stored. It’s import that the .htaccess file go in the actual folder you’re doing the rewrites on and not the parent folder.

That’s it! Permalinks should now work.

Additional Information

Permalinks are very important as you can imagine and the .htaccess rules above actually came initially from Perishable Press’s article The htaccess Rules for all WordPress Permalinks and have been updated for isapi-rewrite 3.0 compatibility.

If your hosted with a host that doesn’t support isapi-rewrite 3.0 for you blog you can learn more about our WordPress Hosting by following that link.

About Jess

Experienced as a Web Developer and Web Server administrator since 1994, in 1999 Jess set out to start a Web Hosting Provider that would leverage the latest in cutting edge and innovative technologies and make them available to businesses in a way that was easy to understand, easy to use and affordable. Today Applied Innovations is a recognized leader in Windows Hosting and specializes in ASP.NET, E-Commerce and Advanced Web Application Hosting.

12 Responses to “The better way to do permalinks in WordPress on Windows”

  1. These instructions fail to work for me. I'm running IIS7 + FastCGI + PHP5 + MySQL on my own computer, with ISAPI_Rewrite and REQUEST_URl fix (request_uri.inc). What happens is that any broken link is redirected to the main page, and all the clean links created by WordPress are also like this: I only see the main page.

    Are you sure you don't have anything more in the .htaccess file? I did take a look into (an older) Apache WordPress installation and the .htaccess file was huge in comparison to these few lines you have here.

  2. Vesa, do you have any plugins installed in your wordpress install? If so disable them. Then attempt the instructions. I have found that when plugins are not compatible with wordpress it affects the url rewrites. — Jess

  3. This is a great solution. I played around with the custom structure and also got it to work with %category%/%postname%/. This is a good alternative when you don't have access to the PHP.INI file on the server as is the case in most shared environments. Your assistance saved the day.

  4. Yeah i had CFORMS Plugin installed. When I deactivated the links started to work. Ugh just dont know if I want to deal with this for the long run.

  5. Chris, that's what you're going to find with any application that uses 3rd party add-ons or plugins unfortunate. This is especially true when the base package gets updated the add-ons lag slightly in being updated.

  6. I've got the exact problem that Vesa had, but disabling all my plugins hasn't changed anything. It looks like something is telling WordPress to use the index.php template no matter what kind of content is being requested via pretty URLs (feed, page, single post, categories, tags, etc.).

  7. Nate, the isapi_rewrite plugin might not be working correctly. I'd check that with your host or in your config. Unfortunately, the domain isn't hosted here so we're unable to help further.

  8. It works great! I searched all over the internet and the answer was right here in my hosting company.

    Thanks,

  9. Hi,
    I have this running locally, I installed the plug in and see the green arrow in IIS. I followed your instructions exactly and disabled all of my plugins and still nothing.

    Any other ideas? Thanks.

  10. PZ, assuming the plugins and theme are not at fault then look at your rules. Create a simple test rule in there and verify that works to verify isapi-rewrite rules work. If the test rule works and the rewrites still don't, then enable debugging as explained in the isapi-rewrite docs and review and post on the helicontech forums they should be able to help from there.

    Jess

Trackbacks/Pingbacks

  1. WordPress Permalinks on IIS - A Better Way | David Carter - Marketing Resources - April 17, 2008

    […] http://www.appliedi.net/blog/2007/10/30/the-better-way-to-do-permalinks-in-wordpress-on-windows/ […]

  2. WordPress Permalinks: Getting It Right Using Windows « dotnetof ASP.NET - December 11, 2009

    […] New Version of a 404 redirect […]