Setting up WordPress permalinks on a Blacknight Windows account with ISAPI Rewrite installed

If your hosting your site on a Blacknight shared windows hosting account, you’ll likely have either ISAPI Rewrite 2 or ISAPI Rewrite 3 installed depending on which particular box you are on. The machine I was on was based on ISAPI Rewrite 2 so rewrite directives had to be placed in httpd.ini. My WordPress install was in the root so I created a httpd.ini file in there and added the following which got custom permalinks working for me. 

[ISAPI_Rewrite]

# For file-based wordpress content (i.e. theme, admin, etc.)
RewriteRule /wp-(.*) /wp-$1 [L]

# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php\?$1 [L]

If your using version 3 of ISAPI Rewrite you should just be able to manually create and use a .htaccess file like on Unix. Placing the following code in your .htaccess file should do the trick, although I’ve not confirmed this as I’m on version 2.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L]

404s with ASP.MVC on IIS 7.5

I was getting page not found errors yesterday when trying to deploy an ASP.Net MVC website which of course worked fine in Visual Studio to IIS 7.5. I tried a couple of things to resolve based on what I had read online including:

  • ensuring appPool was set to pipeline mode of Integrated and targeted towards v4.0
  • ensuring
    <system.webServer>
    <modules  runAllManagedModulesForAllRequests=”true“>
    <validation validateIntegratedModeConfiguration=”false”/>
    </system.webServer>
  • re-registering the .Net framework 4.0 with the aspnet_regiis tool to get all the latest HTTP handlers.

I believe the first two might be required but it was running the aspnet_regiis tool which done the trick for me. As highlighted below, you need to run this as an administrator. Right click on cmd.exe and select ‘Run as administrator’ and then navigate to the .Net framework 4.0 install directory to run the tool.

reregisterNetFramework

 

After you’ve registered 4.0 with IIS you should now see much more HTTP handlers in your IIS configuration manager. The most important one I believe (but I didn’t disable to confirm) in this instance is ExtensionlessUrlHandler-Integrated-4.0

httphanders

404’s disappeared for me after that. Of course during my research there seemed to be a lot of things which could have caused this problem but running aspnet_regiis is what worked for me. I think it might have been because I installed IIS after installing 4.0, but I’m not sure.