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
. 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
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
and we want to replace it into
. 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
where the second result page is
. 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
url.redirect = ( "^/\?s=(.*)" => "/search/$1" )
into configuration on lighttpd.
Finally, the URIs are all search engine friendly and work correctness. Enjoy it. 🙂