URL rewrite support for Lighttpd server

URL rewrite support for Lighttpd server

I was setting up WordPress permalinks with Lighttpd but encounter some problems: mod_magnet module was not available for the Lighttpd installed on my VPS. It turned out that I need to install the module manually and then restart the server:
user@server$ sudo apt-get install lighttpd-mod-magnet
user@server$ sudo lighty-enable-mod magnet
user@server$ sudo /etc/init.d/lighttpd force-reload
For the permalink to work I did the following. Add this piece of code to /etc/lighttpd/lighttpd.conf
$HTTP["host"] == "dev.sudhaker.com" {
    server.document-root = "/sites/sudhaker.com/htdocs"
    magnet.attract-physical-path-to = ( server.document-root + "/rewrite.lua" )
And then
attr = lighty.stat(lighty.env["physical.path"])

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"]
to the rewrite.lua under the server document root directory and it should be up and running.


Leave a Reply

Your email address will not be published. Required fields are marked *

My new Snowflake Blog is now live. I will not be updating this blog anymore but will continue with new contents in the Snowflake world!