At some point in your WordPress-life, you need a pretty permalink (name of the link at the navigation bar). On Apache we can easily use the rewrite module (mod_rewrite) which works pretty well. On the other hand, I found it confusing to make the equivalent rewrite rule on Lighttpd, therefore I use the other module called magnet module (mod_magnet) instead. And these are some simple steps how to use it:
Install Magnet Module
Simply install it from the default repositories.
Dont forget to enable the module:
Lighttpd Configuration
Edit the configuration file:
If you do not use vhosts, add the following to the end of the file:
If you do use vhosts, add that line to your vhost instead:
server.document-root = "/var/www/example.com"
magnet.attract-physical-path-to = ( server.document-root + "/rewrite.lua" )
}
Where example.com is the name of your website and /var/www/example.com is the directory where your website is.
Make a Lua script, assuming that Lua is supported by default (I didn’t have to install anything at that time):
Again, don’t forget change /var/www/example.com to your own setting.
Add the following Lua script into the file, thanks to Sudhaker.
if (not attr) then
lighty.env["uri.path"] = "/index.php"
lighty.env["physical.rel-path"] = lighty.env["uri.path"]
lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"]
end
Reload the module:
Now visit your WordPress’s permalinks configuration, http://example.com/wp-admin/options-permalink.php and use the default or follow this guide. Enjoy!
6 Comments
Why not use mod_rewrite in lighttpd? The linked guide even links to a blog post elsewhere which provides the steps for lighttpd.
Also see the history of the implementation file:
http://redmine.lighttpd.net/projects/lighttpd/repository/revisions/2647/changes/branches/lighttpd-1.4.x/src/mod_rewrite.c
mod_rewrite is way old within lighttpd …
Hi Viðarr,
Thanks for the comment. I tried mod_rewrite in Lighttpd a few years ago while I was configuring a web server. However, I found some issues with the rewrite rules for a server with many virtual hosts. It was more obvious in LUA and mod_magnet worked pretty well. This is very flexible and robust in many server configurations.
Unlike Apache, WordPress still does not provide “standard” rewrite rules for Lighttpd (and probably never will).
The guide links to an article with user-made rewrite rules (which might not work in some configurations), but that article also links to a more general solution with mod_magnet from sudhaker, in which I adapted from.
+1
Just what I was looking for!
I am making the big move from Apache to Lighttpd. The rewrites, are very confusing to me. Furthermore, if I don’t get them correct the first time, it could hurt me as far as SEO.
@Spunky Jones You can run lighttpd on port 88 and test it until you’re quite confident then swap it on.