Wordpress Permalinks in IIS using Custom 404 Redirect
Update
There is a better way to do this now. Take a look at this post that describes it. This page is kept here for all that have already installed this solution.
Original Solution - Outdated Now
This has been tested with WordPress 1.5 and 2.0
If you have any trouble installing it, you can comment here and I’ll try and help you. Also, if you successfully use this on your server, let me know in the same thread. Thanks!
Requirements
• IIS
• Wordpress 1.5 or 2.0
• Ability to change your 404 error page with your web host.
Downloads
This solution requires two files: errorpage.asp and htaccess.txt or htaccess.php.
Installation Instructions
1. Log into the admin section of WordPress.
2. Click on Options -> Permalinks
3. Set your Permalink Structure to “Custom” and enter in a pattern for your permalinks. Wordpress has a section that gives all of the permalink structure tags. Mine is currently set to:
Structure: /archives/%year%/%monthnum%/%day%/%postname%/
Category Base: /archives/category
4. Click Update Permalink Structure
5. Upload htaccess.php and errorpage.asp into the root directory of your blog.
6. The steps used for this next step will vary depending on your hosting provider. Essentially, what you want to do is set a custom 404 redirect to “/errorpage.asp”. It is important that the type of redirect is set to URL. (There are several options.
You can change this directly from within IIS by selecting Properties -> Custom Errors. Select 404. Edit. Set Message Type to URL (you have the option of File, URL or Default). Set it to /errorpage.asp
7. Your done! Try it out. If it doesn’t work, post a comment on my blog and I’ll attempt to help you out.
The script is now dynamic, meaning it uses htaccess.php to figure out what your permalink rules are. htaccess.php gets the rules directly from Wordpress. Previous versions required you to copy/paste the rules from WordPress into htaccess.txt. This feature is still available for those that want to modify the rules from the standard that wordpress puts out.
To do this:
Get the rules either by accessing htaccess.php in a browser and then copying the source, or by navigating to the permalinks section in Wordpress’ admin area.
Paste the rules directly into htaccess.txt.
Change this line in ErrorPage.asp.
Dynamic = True
Change it to:
Dynamic = False
July 24th, 2006 at 7:22 am
[…] 在 Codex çš„ Configuring Permalinks 有æ??到幾個解決方案,以我çœ?å?ƒå„‰ç”¨çš„個性來說, URL Rewrite 還滿å?ˆç”¨çš„。若å?ªéœ€è¦?使用在 wordpress 上,Permalinks for IIS using 404 Redirect 則是é‡?å°? wordpress 的簡易解決方案,以下就ç¨?微介紹一下這個方案。 […]
October 26th, 2006 at 12:36 am
[…] Permalinks on IIS […]
November 19th, 2006 at 10:08 pm
[…] It ended up taking me about 4 hours total to find a solution and I don’t want anyone to go through what I just did. While it wasn’t completely smooth KeyboardFace’s page on how to create a function similiar to Mod_Rewrite on an IIS server for WordPress save me. Hallelujah. […]
December 21st, 2006 at 2:26 pm
[…] Well, almost success. I still had a problem. I had been using Wordpress’s pretty permalinks which do not natively work in IIS, because IIS does not support mod_rewrite. This is a problem for me, after all I had been around for 2 years and my pages are all indexed by a number of search engines. I turned to the web and found an incredibly helpful person in Tom over at KeyboardFace. Tom wrote a slick little ASP script and how-to so that you can get Permalinks for Wordpress working in IIS. The process is relatively simple, though I’ve had some issues that I believe are related to not being able to set my custom error page to be of type “URL” instead of “File” or “Default.” You can comment on your IIS Wordpress Permalinking experiences here. […]
July 22nd, 2007 at 12:44 pm
[…] The problem with my attempt at a clever URL rewriter that didn’t rely on a bizzare/slow automatic 404 error handler was great, in theory, until it occurred to me that the ASP.NET 2.0 engine wouldn’t actually ever fire as the result of a request targeted at anything that doesn’t have an ASP.NET file extension, thus my fantasy of targeting virtual URLs and simulating the apache mod_rewrite() command for URL rewriting went up in some. IIS 7.0 looks like it will be able to offer this kind of virtual URL natively to ASP.NET without having to use ISAPI filters (if you use a shared host, even one as good as DiscountASP.NET, they will not let you install one, ever). […]
October 30th, 2007 at 10:25 am
[…] using a custom 404 redirect as explained on the Keyboard face blog. […]
February 19th, 2008 at 9:05 am
[…] De plus, afin de pouvoir profiter des permalink sous toutes ses formes et sans le "/index.php/" nous devions utiliser soit une astuce grâce aux erreurs 404 ou soit (et pour être plus propre) un module d’ URL Rewriting comme celui de Jon Tackabury que j’ utilise pour ce blog et disponible sur IIS.net. A ce sujet, vous retrouverez sur le site de WordPress plus d’ informations sur les permalink et IIS. […]
March 9th, 2008 at 7:33 pm
[…] Permalinks on IIS […]