WordPress, IIS, and ISAPI Rewrite
July 15, 2008
One of the servers that I administer is a traditional Windows Server 2003 box (ASP.NET, SQL Server, etc.). Recently, we decided to add a quasi-internal, CMS-like website to manage and track software projects. Since I’m a big fan of WordPress, I decided to attempt an install on IIS. Unfortunately, IIS doesn’t support mod_rewrite and thus pretty URLs. Luckily, following the steps below will fix that problem.
- Install ISAPI Rewrite (free version available) and install it on your server
- Modify WordPress’ permalink settings to fit your desired structure.
- Have WordPress create an .htaccess file for you.
- Copy WordPress’ .htaccess directive starting at the “RewriteBase” directive into ISAPI Rewrite’s .htaccess file
- Modify the wp-settings.php file adding the following code somewhere around line 58 (before the preexisting IF statement):
- if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
- $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
- }
And voila!, you have pretty URLs with IIS.
–Adam
YOU are the man! I have been trying to figure this out for days… THANK YOU! works like a charm!
Kim,
Thanks. I glad that it helped someone else out.
–Adam
Have you ever used the isapi rewrite outside of wordpress? I have a custom built classic asp website that I am trying to use it on – and my head hurts from banging it against the screen – any tips regarding that usage?
Kim,
According to http://www.velocityreviews.com/forums/t120907-httpxrewriteurl.html, the ISAPI Rewrite module uses the ‘HTTP-X-REWRITE-URL’ variable to hold redirection information. As such, it would be your job in asp to examine that variable. Personally, I haven’t done a whole lot in classic ASP, but in .NET, I’d venture to guess that the variable can be read using something in the Response or Request object.
–Adam