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.


  1. avatar
    wrote this comment on

    Can you provide the rewrite code for wp mu installs in a subdirectory?

    For example, my wp multisite install is in the following subdirectory

    with subsequent new sites being created as "myhome" with the url being http://www.mysite.com/myblogs/myhome

    Thank you.

  2. avatar
    wrote this comment on

    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.

  3. avatar
    wrote this comment on


  4. avatar
    wrote this comment on

    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.


  5. avatar
    wrote this comment on

    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.

  6. avatar
    wrote this comment on

    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

  7. avatar
    wrote this comment on

    You're welcome... I guess :-)

  8. avatar
    wrote this comment on


    Will the above rules work with other permalinks? Say:


    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?

  9. avatar
    wrote this comment on

    Did you try yet? The rules above should really cover all permalink structures.

  10. avatar
    wrote this comment on

    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.

  11. avatar
    wrote this comment on
    Hi Nicolas, After rewrite it runs my application twice. Do you know why? And if it is a normal working of lighttpd could you tell me how can detect duplicate request by using environment variables? Thank you,
  12. avatar
    wrote this comment on
    Hmmm. I'm not sure what you mean?
  13. avatar
    wrote this comment on
    hey, why the heck I can't see the post but only the comments? I really need some urgent answers, and this seems to promising, but... zonk... WTF?
  14. avatar
    wrote this comment on
    Aaaah... sorry, there was a bug in this website's code. It's fixed by now.
  15. avatar
    wrote this comment on
    Okay, so with the new wordpress multisite and lighttpd 1.4.x I got it working with this: note that I have everything installed under /blog/ url.rewrite-if-not-file = ( "^/blog/index\.php$" => "$0", # this does nothing, especially since index.php should be a file "^/blog/([_0-9a-zA-Z-]+/)?wp-admin$" => "/blog/$1wp-admin/", # this adds a / to /wp-admin "^/blog/$" => "$0", # this seems unnecessary, but I kept it for fun "^/blog/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" => "/blog/$2", # this forwards wordpress files "^/blog/([_0-9a-zA-Z-]+/)?(\?.*)" => "/blog/$2", # this fixes search "^/blog/." => "/blog/index.php" ) Best of luck! MVirts
  16. avatar
    wrote this comment on
    Thanks for the input. My post is pretty old, and I haven't really used lighttpd or wp in years.


Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.
DjangoPythonBitcoinTuxDebianHTML5 badgeSaltStackUpset confused bugMoneyHackerUpset confused bugX.OrggitFirefoxWindowMakerBashIs it worth the time?i3 window managerWagtailContainerIrssiNginxSilenceUse a maskWorldInternet securityPianoFontGnuPGThunderbirdJenkinshome-assistant-logo