Welcome Guest, Not a member yet? Register   Sign In
Quick and Dirty Howto: Using mod_rewrite for Lighttpd (Lighty)
#1

[eluser]smidoid[/eluser]
I'm in the process of moving some of my sites from Apache to Lighttpd which is pretty simple overall, but the URI rewriting rules are different in Lighty. Lighty's performance is at least as good (and often better) than Apache, but unlike Apache it can handle thousands of requests without taking the server into swap! PHP is configured as fast-cgi - so I had to roll my own, but your mileage may vary.

The most common task is to hide INDEX.PHP in the URL, so I've included this and a couple of other tricks which may be handy. These rules need to be added to Lighttpd.conf and although this isn't for everyone, someone will hopefully find it useful.

Code:
url.rewrite-once = ("^/(asset|ckeditor)/(.*)$"  => "/$1/$2",
                    "^/(robots\.txt)$" => "/$1",
                    "^(.*)$"  => "/index.php/$1")

The first line is where you put a list of directories that you don't want mangled and to pass as they are. In this example my assets (images, css) and the CKEditor directories are passed without change.

The second line (which is very important if you use Robots.txt) allows the engines to actually read it!

Finally, all other requests are passed through with the usual INDEX.PHP prefix to make neater URIs.




Theme © iAndrew 2016 - Forum software by © MyBB