views:

38

answers:

1

Hi, I have an address on my site like so:

http://www.example.com/lookup?q=http%3A%2F%2Fgigaom.com%2F2010%2F10%2F10%2Fangry-birds-for-windows7-phone-dont-count-on-it%2F

In this example, the dot in the 'gigaom.com' part of the query string is screwing with lighttpd and my rewrite rules. I get a 404 with the dot in, no 404 if I take the dot out. My rewrite rules are below. In case it makes a difference, I'm using symfony 1.4.

If anyone could shed some light on this problem it would be much appreciated!

url.rewrite-once = (
    "^/(.*\..+)$" => "$0",
    "^/(.*)\.(.*)"    => "/index.php",
    "^/([^.]+)$"      => "/index.php/$1",
    "^/$"             => "/index.php"
  )

For anyone having trouble with lighttpd and symfony (I know you're out there, cause there are plenty of unresolved threads on the issue) I ended up solving and answering it below.

A: 

OK so after much debugging with the help of:

debug.log-request-handling = "enable"

^^ This is a lifesaver for when you're trying to debug rewrite rules in lighttpd! (it logged everything for me to /var/log/lighttpd/error.log)

I've figured it out. For all those people having trouble getting symfony to work with lighttpd (including the dot problem!) here's a working set of rules:

url.rewrite-once = (
    "^/(js|images|uploads|css|sf)/(.*)" => "$0", # we want to load these assets as is, without index.php
    "^/[a-zA-Z_-]+\.(html|txt|ico)$" => "$0", # for any static .html files you might be calling in your web root, we don't want to put the index.php controller in front of them
    "^/sf[A-z]+Plugin.*" => "$0", # don't want to mess with plugin routes
    "^/([a-z_]+)\.php(.*)\.(.*)$" => "/$1.php$2.$3", # same concept as rules below, except for other applications/environments (backend.php, backend_dev.php, etc)
    "^/([a-z_]+)\.php([^.]*)$" => "/$1.php$2", # see comment right above this one
    "^/(.*)\.(.*)$"    => "/index.php/$1.$2", # handle query strings and the dot problem!
    "^/([^.]+)$"      => "/index.php/$1", # general requests
    "^/$"             => "/index.php" # the home page
  )

If anyone has more trouble, post here. Thanks!

Marc
What happens if there are two dots in the query, 'www.gigaom.com'?
Joel
Just tried it, it works. I've also updated the rules for a bunch of other cases I've discovered over the past hour (other applications like backend.php for instance) and plugin files. The only thing I have left to resolve is capital letters, like backend.php/News as a route.
Marc