Auto Answer FaceTime Call | When FaceTime was introduced by Apple the first time, I was thinking, it can be ...

URL Rewriting for WordPress in IIS with wp_url_rewriting and patch

Thursday, May 5th, 2011

There are several ways to use URL rewriting for WordPress in IIS. I'm using wp_url_rewriting for my client. Recently, my client upgraded his WordPress to 3.1 which cause a problem that the page navigation does not work correctly.

Symptom: The page link in a category page, does not contain the category slug. Ex. in http://sampledomain/samplecate/, the page link should be http://sampledomain/samplecate/page/2, but it shows like http://sampledomain/page/2.

This does not happen on my Apache server. So I checked out wp_url_rewriting installation note and I found this:

3). Do a little hack to WordPress file ‘link-template.php’ to make paging works well for categories:(NOTE: You don’t need to do this step if you are using WordPress 2.3.0 or newer)

open file /wp-includes/link-template.php and find the following code:....

From 2.3.0 to 3.0.x, no need to do the hack. Since 3.1.0, it becomes a must again. The original hack does not working. It's been moved to another file. So do the hack as follows:

open file /wp-includes/functions.php and find following code:

  1. function add_query_arg() {
  2. $ret = '';
  3. if ( is_array( func_get_arg(0) ) ) {
  4. if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) )
  5. $uri = $_SERVER['REQUEST_URI'];
  6. else
  7. $uri = @func_get_arg( 1 );
  8. } else {
  9. if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) )
  10. $uri = $_SERVER['REQUEST_URI'];
  11. else
  12. $uri = @func_get_arg( 2 );
  13. }

Replace the $_SERVER['REQUEST_URI'] with $_SERVER['PATH_INFO']

Then wp_url_rewriting will work again.

BTW, after fixing this, I found some updates of ISAPI_Rewrite. The lite version could work well for WordPress. I used that before. I remember there were some limitations for the lite version. Since this article was written on Feb 17th, 2010. I guess it should work fine. If so, this could be a better solution for there's no hack needed.

 

Solving PHP has encountered an Access Violation

Monday, August 31st, 2009

In short: it's caused by compatibility of different version of MySQL.
I have installed php + MySQL on two similar servers. The first one was running without any problem while the second one gave me "PHP has encountered an Access Violation". Here is the version of each component:

  • PHP: 5.2.8
  • MySQL: 5.1.34
  • Zend Optimizer: 3.3.3 (The key point)

On the 2nd server, I installed MySQL before PHP. When deploying the web application, "Access Violation" appeared. I reinstalled MySQL, problem solved. I remembered the difference in phpinfo() between 1st server and 2nd server: MySQL Client API version - 5.0.51a vs 5.1.34. Strange that I installed 5.1.34 on both servers, why the 1st one got older version of API? I did not pay more attention on this question for the problem was solved at that time. But after no more than 24 hrs, same problem happened again. This time, I remembered that I forgot to install Zend Optimizer on 2nd server. Then I install it and found that the API version changed to 5.0.51a... Now I know why the 1st server is running well: Zend Optimizer replaced the MySQL API for php.
My experience is proven here, exact same problem.
It teaches me the lesson again, which, though, I already knew but often forgot to apply:
The latest version may not be the best