Sunday 23rd of November 2008

Running Worpress on IIS

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ... Posted on: April 8th, 2008 by admin

Wordpress was never designed to work on IIS but Apache. There is a simple solution though which uses the 404 page redirect to point the permalink back to index.php.

Permalinks are a feature of wordpress to change posts into seo friendly posts.

The posted solution worked to a point for me. However it was only to a point because my site has 2 wordpress installations. The trouble was that the 404 redirection went straight to an installation rather than either. This meant that one worked and the other went to page not found in the version that worked.

I have developed a work around to allow two installations to work on IIS. In the installation that receives the 404 redirection you will find wp-config.php. Inside this file you will see the line;

$table_prefix  = ‘wp_news_’;

This line points to the set of database tables that wordpress uses. I simply changed this to test which version was working and point to the correct version;

$qs = $_SERVER[’QUERY_STRING’];
if (strpos($qs, “/news/”) > 0)
{
 $table_prefix  = ‘wp_news_’;   // Only numbers, letters, and underscores please!
}
else
{
 $table_prefix  = ‘wp_info_’;   // Only numbers, letters, and underscores please!
}

My two installations are info and news. You can add whatever you like in here. I also edited the 404 redirection page from the example listed on the web to the following. Again this is to redirect both my installations.

<?php
$qs = $_SERVER[’QUERY_STRING’];
if (strpos($qs, “/news/”) > 0)
{
  $my_wp_url = “http://” . $_SERVER[’SERVER_NAME’] . “/news”;
  $_SERVER[’REQUEST_URI’] = substr( $_SERVER[’QUERY_STRING’], strpos($_SERVER[’QUERY_STRING’], $my_wp_url)+strlen($my_wp_url));
  $_SERVER[’PATH_INFO’] = $_SERVER[’REQUEST_URI’];
  include ‘C:/Inetpub/vhosts/overseas.com.au/httpdocs/news/index.php’ ;
}
else
{
  $my_wp_url = “http://” . $_SERVER[’SERVER_NAME’] . “/info”;
  $_SERVER[’REQUEST_URI’] = substr( $_SERVER[’QUERY_STRING’], strpos($_SERVER[’QUERY_STRING’], $my_wp_url)+strlen($my_wp_url));
  $_SERVER[’PATH_INFO’] = $_SERVER[’REQUEST_URI’];
  include(’index.php’);
}
?>

Please let me know if this does or doesent work for you. This has been a nightmare to  get working and in the end a simple solution won the day (as it normally always does).

Thanks for finding us :)

    Related posts

Leave a Reply

You must be logged in to post a comment.

Headlines

Feeds