There has been quite a bit of comments going back and forth on the code that I wrote to enable permalinks for Wordpress on IIS since I put it up on the site. Just recently, Einar Egilsson posted an extremely helpful bit a code in the comments. It’s a much better and cleaner way of accomplishing the same thing.
I was always aware that my solution was a little odd in that it used ASP. WordPress is written in PHP and to use ASP requires odd work-arounds. Einar gave us a great simple solution that uses PHP. It too requires 404 redirects, though.
It’s requirements are:
To install, copy and paste this text into a file named wp-404-handler.php:
< ?php
$qs = $_SERVER['QUERY_STRING'];
$_SERVER['REQUEST_URI'] = substr($qs, strpos($qs, ':80')+3);
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
include('index.php');
?>
Next set the 404 error page to /wp-404-handler.php. If it gives you a choice between file and url, choose url.
Lastly, make sure you enable permalinks in the Wordpress control panel under Options > Permalinks.
That should do it.
Thanks to Einar for posting this in the comments and thanks to CaptainN who first wrote about in the Wordpress support forums.
A recent post “7 Easy Steps to a Pimped Out Money Making Blog” got me thinking about what plugins bloggers thought were “essential” to a good blog.
That post lists out several very good plugins that I’m going to be looking at for my own blog.
What other plugins would you consider a “must have” for a good blog?
In a previous post, I mentioned that I was investigating a way to use real permalinks without using any of the ISAPI mod_rewrite dlls. For the uninitiated, mod_rewrite is not natively supported in IIS (Window’s server), and to get the same functionality, you have to install separate programs. I’ve done that and that is how this blog has survived on a Windows server for the past year or so.
I was convinced that needn’t be the case though. There must be a way to have permalinks without having to install a whole separate mod_rewrite program (or extension). I detailed my plan in this post.
Well, I finally got around to it – and the plan worked!
Here’s the gist of it. It uses custom 404 redirect to send all “Page Not Found” errors to a script that reads a bunch of regular expressions (don’t worry, you don’t have learn regular expressions to use this) and figures out what page to feed back.
Now, some people may find my solution a bit odd considering it is written in ASP. You used ASP to extend wordpress?? Yes, and it worked
.
More detailed instructions, and a link to the needed files are located here:
Wordpress 2.0 came out a little while ago. I’m installing it on a new site and ran into a problem on the install step.
The fix is to comment out line 38:
Line 38 in wp-settings.php is a “fix” for (quote):
// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requestsIs this the case with your server?
Note: I’m running WordPress on a Windows 2003 server with MySQL on the same box. That might have been the source of the error.
Took a little while, but I managed to reset my root password. I’m installing a new blog and forgot the root. Here’s the official documentation on how to do it:
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
As I mentioned in a previous post, WordPress installed on IIS can be somewhat aggravating because it doesn’t have permalink functionality out of the box. You have to jump through several hoops to get it to work. Mine works for the most part now, but it doesn’t work when you click the “next” link on pages that have large numbers of posts.
I’ve been thinking about a possible solution to this. Would it be possible to use a custom 404 page on IIS to act as a intermediary page that does what mod_rewrite would normally. Here’s how it would work:
1. Set IIS to redirect all 404 errors to a custom page that would handle all interpretation of the permalinks. In IIS, you have the option of specifying whether it i s a file, or a url. It must be set to “url” to work. Here’s a page that goes into this theory. http://evolvedcode.net/content/code_smart404/guide-rewrites.asp
2. All that would be left to do then would be to write a page that interpreted the rules that wordpress gives you and redirects accordingly.
Sorry if this was a little confusing, I’ll be trying this out in a week or so and I’ll let you know the results in a clearer format.
Related Threads from WordPress.org
IIS URL Rewrite Rules?
Enabling Search engine Friendly (Optimized ) URLs in IIS Without Mod_rewrite
This also looks to be promising: IIS Mod’s Free URL ReWrite
It appears I was a little quick to talk about how easy it was to install this on a Windows server. 3 hours later!
WordPress was really written to take advantage of all the benefits of Apache. It uses a feature of Apache called mod_rewrite to make urls like this “site.com/index.php?year=2004&monthnum=07&day=07″ look like this “site.com/archives/2004/07/07/”. This is incredibly helpful with the search engines as they often don’t read URLs that have ?’s in them.
While you can use WordPress without this feature enabled, I feel it is extremely important. I was on the verge of uninstalling it when I finally found this article that solved my problems.
The problem was that Windows web server, IIS, doesn’t have an equivalent feature to mod_rewrite. In short, the solution suggested installing an add on to IIS called ISAPI_Rewrite . You can download the lite (freeware) version of it from here.
Rather than quote everything that I did, this article explains it very well.
For the past 2 weeks or so, I’ve been determined to create a blog about my travails in learning .NET. Well, I shouldn’t exactly say travails, but definitely, my trials. I searched and searched for the best blog software written in .NET.
See I was convinced that it just would not go to have a blog about .NET using some other platform. I tried installing CommunityServer – ran into several problems. First of which was that it didn’t like .NET 2.0. Second of which I wanted just a blog. Their photo gallery and forums were great, but I didn’t want to go there.
Anyway, I finally broke down and installed WordPress on my machine. Amazingly it only took about 5 minutes to install like that tutorial said. I happened to have PHP and MySQL already installed on my Windows 2003 machine. That made it significantly easier, but still.