Pretty permalinks and search urls for WordPress on lighttpd

To make a blog Search Engine (SE) friendly, one feasible way is to make all requested URIs permanently. It is easier for Apache web service than lighttpd, because there are more resources and technical notes on the Net. This post is about how to set up the pretty permalinks and to introduce a partial solution for the unfriendly search URIs for WordPress 3.3 on lighttpd.

First, for pretty permalinks, the reference is Using Permalinks. I want to use the Day and Name format as an SEO friendly URI. Unfortunately, except for Apache’s rewrite rules, there always exist index.php as a bridge for processing. Then the format seems

/index.php/%year%/%monthnum%/%day%/%postname%/

. To eliminate the bridge string, we can still use Custom Structure and set up rewrite ules on lighttpd.

There are ways to write proper rewrite rules within lighttpd. Based on the references: lighttpd rewrite rule for wordpress 3 and other resources from Google (keywords: lighttpd, wordpress, permalinks), the final configuration is very simple. We only need to add

1
server.error-handler-404 = "/index.php"

into lighttpd. This rule indicate that the request will be passed into the index page when the page (or URI) is not exist physically. It is depend on the truth that almost all of the requests are handled by the index page (like the posts, pages, feeds).

Second, to fix the unfriendly search URIs, we can use plugins or to add a redirect rule into lighttpd. The search URIs are formatted as

/?s=terms

and we want to replace it into

/search/terms

. It is SEO friendly and is VERY IMPORTANT when we use 404 handler as rewrite rule. For example, if there are more than one page for the search term T, the first result page’s URI is

/?s=T

where the second result page is

/page/2/?s=T

. Because the request of page 2 is not exist physically, the request will be passed into index.php and the search term (?s=T) will be ignored. The reason for why search will be ignored remains unknown.

To make the search and paged view work, we can set a redirect rule to fix it by adding

1
url.redirect = ( "^/\?s=(.*)" => "/search/$1" )

into configuration on lighttpd.

Finally, the URIs are all search engine friendly and work correctness. Enjoy it. 🙂

Clean up, merge posts and add tags

It seems some posts in my blog should do clean up and merge for the title, slug or contents. Because posts here are moving several times(no matter the version of wordpress or system environment of sits).

On the other hand, they must be added relative tags for searching and convenience reading. I’ll do this when I’m free.

New site, new domain and mobile version

This is first post with brand new domain – nullspace.me hosting on GoDaddy.com and VPS on Hostitek. It is a different experience to build a system via VPS and OpenVZ. For days of work, some services are back.

On the other hand, the mobile view is now supported via Device Theme Switcher plugin with Carrington mobile theme. I’ve test the MobilePress plugin recently but the comment related functions are broken. Now with mobile devices, the theme will transient automatically fit in screen size with a simple layout.

In the beginning of 2012, it’s a good point to start with. 🙂