30th Apr, 2008

Permalinks on IIS wordpress

Owen pointed me to a snippet that fixes wordpress permalinks on IIS. Although the solution is not very clean, it works very well. What you need to do is set a 404 error page from your website control panel and point it to a *.php file with the following code.

<?php
$qs = $_SERVER['QUERY_STRING'];
$_SERVER['REQUEST_URI'] = substr($qs, strpos($qs, ‘:80′)+3);
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
include(’index.php’);
?>

When a user visits a permalink url, IIS will throw a 404 exception which will be handled by the above code. The logic is dead simple: The REQUEST_URL and PATH_INFO servervariables are overridden by the permalink path. In this case it is : /2008/04/30/permalinks-on-iis-wordpress/.

The last line simply loads index.php and opens the correct page because PATH_INFO and REQUEST_URL are correctly set.

Have you ever been to Malta? All you need to know is a click away! Malta Travel Guide, Bargain Accommodation in Malta, Malta Hotels

Leave a response

Your response:

Categories