Enabling "Pretty URLs" on Lighttpd-based c5

Permalink
I've decided to run a c5 project on lighttpd instead of Apache. I really wanted to 'Enable Pretty URLs', but got stuck on the issue of translating the Apache rewrite snippet provided when you check the option in Dashboard >> Sitewide Settings >> Linking.

After several dead-ends in researching the issue, I think I've got it. For reference, I'm using:

url.rewrite = (
"^/(.+)/?$" => "/index.php/$1"
)


It works so far. Still, I'd be curious (and very appreciative) to hear from anyone who sees potential problems with it. Thanks.

 
Remo replied on at Permalink Reply
Remo
doesn't that rewrite files too?

like: /files/mypicture.jpg

there should be a condition imho. lighttpd might do this somewhere else, but if not, you should probably add it..
lgb replied on at Permalink Reply
You're right. Just caught that. Although it seems to be affecting some files and not others. Most images are OK, but a few aren't. PDFs/DOCs aren't.

Anyone have an idea about how to translate those Apache "RewriteCond" conditions provided by c5 for lighttpd?

If I can't hang on to lighttpd, I guess it's OK. The SEO/usability aspect of this site is more important.

Thanks.
celmlauzis replied on at Permalink Reply
url.rewrite = (
"^/([^.?]*)$" => "/index.php/$1"
)

Working at all 100%. :>
abraamz replied on at Permalink Reply
abraamz
I dont know how does that work but my host is using lighttpd and when i asked for the same thing he made something called a "lua rewrite"

if (not lighty.stat(lighty.env["physical.path"])) then
        lighty.env["physical.path"] = lighty.env["physical.doc-root"] ..
"index.php"
end

It worked for my site!
harryr replied on at Permalink Reply
harryr
Adding a few lines of code to index.php to use $_SERVER['REQUEST_URI'] allows concrete5 to be setup as the error handler in lighttpd.
$p = strpos($_SERVER['REQUEST_URI'], '?');
$_SERVER['PATH_INFO'] = substr($_SERVER['REQUEST_URI'], 0, $p === FALSE ? strlen($_SERVER['REQUEST_URI']) : $p);
unset($p);


Then in your lighttpd config:
server.error-handler-404 = "/index.php"


Pretty easy and much less mess to sort out.