WordPress 3.0 network lighttpd rewrite rules
I recently installed my first WordPress network on lighttpd and was looking for rewrite rules. This post is correct except for the rewrite rule for files. I supposed it's a change that was introduced in 3.0, or maybe earlier. Anyway, here are updated rewrite rules:
In your lighttpd.conf
:
$HTTP["host"] =~ "domain\.com" {
simple-vhost.default-host = "domain.com"
include "wpmu-rewrite.conf"
}
And wpmu-rewrite.conf
:
url.rewrite-once = (
"^/(.*/)?files/$" => "/index.php",
"^/(.*/)?files/(.*)" => "/wp-includes/ms-files.php?file=$2",
"^(/wp-admin/.*)" => "$1",
"^/({_0}+/)?(wp-.*)" => "/$2",
"^/({_0}+/)?(.*\.php)$" => "/$2",
)
What's changed from the other site's example is the ms-files.php
rewrite rule.
Can you provide the rewrite code for wp mu installs in a subdirectory?
For example, my wp multisite install is in the following subdirectory
htttp://www.mysite.com/myblogs/
with subsequent new sites being created as "myhome" with the url being http://www.mysite.com/myblogs/myhome
Thank you.
Hi Cliff, I don't use subdirectory installs myself, so I don't really know. Just look for pre-3.0 rewrite rules and fix the ms-files.php line. Should be really easy.
Thanks
This is very helpful advice! I'm still somewhat new to lighttpd but I'm switching to it for some of our WPMU sites for performance reasons.
Thanks!
Yeah, I also switched to lighttpd when my old server ran out of memory too often and have been very happy every since. If you have a lot of traffic you should probably try nginx as well. It seems to be quite popular and does reverse proxying out of the box which could be useful in your case.
Caro Nicolas.
Eu estou no Brasil...quero te agradecer imensamente por ter resolvido o meu problema no multisites - com a regra anterior havia problemas no upload de imagens - com a sua regra o meu problema foi resolvido - estou muito feliz - muito obrigado
You're welcome... I guess :-)
Hello,
Will the above rules work with other permalinks? Say:
/%post_id%/%postname%
I see some solutions that has:
"(\?.*)$" => "index.php$1",
"." => "index.php"
but would adding "." would be like a fallback if everything else fails in the rules? Like adding more burden to index.php/wordpress?
Did you try yet? The rules above should really cover all permalink structures.
Hi Nicolas,
I did try your solution but had 404's on /%post_id%/%postname% permalinks. I'm also using sub-domain/multisites. I ended up adding:
"." => "index.php"
It worked but I'm not sure if this is the correct way to do it.