Not long ago I switched from LAMP to WIMP (windows2k3+iis6+mysql5.2+php5.2), and WordPress lost two important features: one is permalinks (static URLs), and the other is email sending.
I’ve just perfectly solved the permalink problem, so I’ll share the method. (A so-called permalink is something like http://www.flashj.cn/wp/wimp-wordpress-permalink.html这样的格式)
Because Windows doesn’t support .htaccess, to do rewrite you need to download an ISAPI_Rewrite component to implement rewriting. I tried it, and personally I didn’t find the result very ideal.
I saw a clever method online for implementing permalinks with a 404 page, and after adapting it, it felt pretty good. The principle is: write a 404.php file that forwards requests to WordPress’s index.php.
The version that’s commonly circulated now is:
- Create a PHP file with the following content:
Save as 404.php 2. Put this 404.php file in the WordPress root directory 3. Set IIS’s 404 page to 404.php in the WordPress root directory 4. Enable permalinks in the WordPress admin panel
In other words, 404.php acts as a rewrite.
However, when implementing it I ran into two problems: 1. Subdirectories Friends who often read my blog should know that my domain is flashj.cn, the landing page is www.flashj.cn, and I actually have two WordPress blog installations, in the www.flashj.cn/wp and www.flashj.cn/personalblog directories, so I can’t directly set the site’s 404 file like friends with standalone sites can. 2. Chinese garbled text Because the IIS6 on Chinese WIN2k3 uses GBK encoding, while WordPress uses UTF-8 encoding, Chinese characters in permalinks make WordPress unable to recognize them.
After my “improvements”, I’ve now successfully made them static. Here’s how:
Enable support for extension=php_mbstring.dll in php.ini (it’s usually enabled anyway)
Write a 404.php like this
I just added Chinese transcoding to the commonly circulated online version, converting IIS’s GBK to the UTF8 that WordPress needs.
Put this 404.php file in the /wp and /personal directories (one in each of the two WordPress directories)
In IIS, create applications for the subdirectories: Open IIS Manager, switch to the flashj.cn site, and create applications for the /wp and /personalblog subdirectories. For example: open the properties of the “site/wp” subdirectory, and in the “Application Settings” area at the bottom of the “Directory” tab, click “Create” application. This way, the subdirectory can now have its own independent error page.
Set IIS’s 404 page: Following step 4, switch to the “Custom Errors” tab and set the 404 page. The key here is to change the 404 setting to: message type URL, URL /subdirectory-name/404.php (mine is /wp/404.php)
Enable permalinks in the WordPress admin panel
Leave a comment at the end of this post to say hi and celebrate the success
I’ll go continue looking into how to get the email feature working…