Posted by Anonymous on January 30, 2012 at 11:37pm
Here is my lighttpd config. It supports shortened URLs for the /files & /themes.
$SERVER["socket"] == ":80" {
###
# drupal specific stuff
###
# Deny access to backup_migrate module dumps
$HTTP["url"] =~ "^(/sites/(.)/files/backup_migrate/)" {
url.access-deny = ("")
}
$HTTP["url"] =~ "/files/backup_migrate/" {
url.access-deny = ( "" )
}
###
# drupal vhosting
###
$HTTP["host"] =~ "(.).example.com$" {
### default to drupal 7
server.document-root = "/local/www/drupal-7/"
index-file.names = ( "index.php" )
### shorten /files, /themes
### 2012-01-30 - randall
### %0 = entire hostname
### %1 = prefix of ..example.com
url.rewrite-once = ( "^/files/(.)$" => "/sites/%0/files/$1",
"^/themes/(.)$" => "/sites/%0/themes/$1")
### clean urls for >= lighttpd 1.4.24
### Reference URL #1
### 2012-01-05 - randall - fix for drupal 7 with image cache
url.rewrite-if-not-file = (
"^\/([^\?])\?(.)$" => "/index.php?q=$1&$2",
"^\/(.)$" => "/index.php?q=$1"
)
### "Fix" for Drupal SA-2006-006 (but let imagecache work)
### Reference #2
$HTTP["url"] =~ "^(\/sites\/(.)\/files\/)" {
$HTTP["url"] !~ "^(\/sites\/(.*)\/files\/imagecache\/)" {
fastcgi.server = ()
cgi.assign = ()
scgi.server = ()
}
}
### deny access to other files directly
url.access-deny = ( "~", ".engine", ".inc", ".info", ".install", ".module", ".profile", ".test", ".po", ".sh", ".sql
", ".mysql", ".theme", ".tpl", ".xtmpl", "Entries", "Repository", "Root" )
###
# drupal vhosting
###
$HTTP["host"] == "testd6.sites.example.com" {
server.document-root = "/local/www/drupal-6/"
}
$HTTP["host"] == "testd7.sites.example.com" {
server.document-root = "/local/www/drupal-7/"
}
}
###
# end of port 80 hosting
###
}
Comments
Reference URLs
My post was detected as spam if I included these URLs for reference, so trying here in the comments:
References:
1 - http://tinyurl.com/24rulps
2 - http://tinyurl.com/72qzhlh
Doesn't pass Clean URLs test on 7.15 for me
I've tried using this info and the info here http://drupal.org/node/43782
This part in yours:
url.rewrite-if-not-file = (
"^\/([^\?])\?(.)$" => "/index.php?q=$1&$2",
"^\/(.)$" => "/index.php?q=$1"
)
differs from the same portion I find other places:
url.rewrite-if-not-file = (
"^\/([^\?])\?(.)$" => "/index.php?q=$1&$2",
"^\/(.*)$" => "/index.php?q=$1"
)
However, after spending hours trying different combination I have found different places in the forums, I have not gotten the Clean URLs test to pass.
I would be curious to see documentation of what must be done to pass the tests? What are the tests? Some sort of "this is everything Clean URLs handling requires" would help.
Is anyone getting these tests to pass with lighttpd 1.4.30 and Drupal 7.15?
I have not yet tried the mod_magnet lua setups, but they don't seem very recent, so I didn't think they were worth the effort for another failure without confirmation that they work with 7.
One problem I have is that people seem to forget to say what version they are using for things.
Drupal 7.15 & lighttpd 1.4.27
I'm using Drupal 7.15 & lighttpd 1.4.27 as of now. Here is my most recent config:
#--------------------
# cache control
#--------------------
$HTTP["url"] =~ ".html$" {
setenv.add-response-header = ( "Cache-Control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0" )
etag.use-inode = "disable"
etag.use-mtime = "disable"
etag.use-size = "disable"
}
#--------------------
# vhost handling
#--------------------
$SERVER["socket"] == ":80" {
###
# drupal specific stuff
###
# Deny access to backup_migrate module dumps
$HTTP["url"] =~ "^(/sites/(.)/files/backup_migrate/)" {
url.access-deny = ("")
}
$HTTP["url"] =~ "/files/backup_migrate/" {
url.access-deny = ( "" )
}
###
# old way of doing this
###
## clean urls
####url.rewrite = ( "^/(?!(misc|theme|module|site))([^?])\??(.)$" => "/index.php?q=$2&$3" )
## clean urls
#####magnet.attract-physical-path-to = ( "/etc/lighttpd/drupal.lua" )
###
# drupal vhosting for *.example.com
###
$HTTP["host"] =~ "(.).example.com$" {
### default to drupal 7
server.document-root = "/local/www/drupal-7/"
index-file.names = ( "index.php" )
### shorten /files, /themes
### 2012-01-30 - randall
### %0 = entire hostname
### %1 = prefix of ..ucsb.edu
url.rewrite-once = ( "^/files/(.)$" => "/sites/%0/files/$1")
###"^/themes/(.)$" => "/sites/%0/themes/$1")
### Deny access to backup_migrate module dumps
$HTTP["url"] =~ "^(\/sites\/(.)\/files\/backup_migrate\/)" {
url.access-deny = ("")
}
### clean urls for >= lighttpd 1.4.24
### http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModRewrite#urlre...
### 2012-01-05 - randall - fix for drupal 7 with image cache
url.rewrite-if-not-file = (
"^\/([^\?])\?(.)$" => "/index.php?q=$1&$2",
"^\/(.)$" => "/index.php?q=$1"
)
### "Fix" for Drupal SA-2006-006 (but let imagecache work)
### http://www.linode.com/forums/viewtopic.php?t=5300%3E
$HTTP["url"] =~ "^(\/sites\/(.)\/files\/)" {
$HTTP["url"] !~ "^(\/sites\/(.)\/files\/imagecache\/)" {
fastcgi.server = ()
}
}
### deny access to other files directly
url.access-deny = ( "~", ".engine", ".inc", ".info", ".install", ".module", ".profile", ".test", ".po", ".sh", ".sql", ".mysql", "
.theme", ".tpl", ".xtmpl", "Entries", "Repository", "Root" )
# make an external redirect
# from any www.host (with www.) to the host (without www.)
$HTTP["host"] =~ "^([^.]+.[^.]+.[^.]+)$" {
url.redirect = ( ".*" => "http://www.%1" )
}
I have a simple host block
I have a simple host block like below. Is there some obvious reason it should fail?
$HTTP["host"] == "www.example.com" {
server.document-root = "/home/user/www.example.com/www"
accesslog.filename = "/home/user/www.example.com/logs/access_log"
# I've tried with and without this.
#server.error-handler-404 = "/index.php"
fastcgi.server = ( ".php" =>
( "localhost" => ( "socket" => "/tmp/userphpfastcgi.socket", ) )
)
# Tried lots of stuff like this
# url.rewrite-if-not-file = (
# "^/([^.?])\?(.)$" => "/index.php?q=$1&$2",
# "^/([^.?])$" => "/index.php?q=$1",
# "([a-zA-Z-.\/\?\=\&])" => "/index.php"
# )
# Just tried this
url.rewrite-if-not-file = (
"^\/([^\?])\?(.)$" => "/index.php?q=$1&$2",
"^\/(.)$" => "/index.php?q=$1"
)
# tried with and without this... I wish I knew what the tests were...
url.access-deny = ( "~", ".engine", ".inc", ".info", ".install", ".module",
".profile", ".test", ".po", ".sh", ".sql ", ".mysql", ".theme",
".tpl", ".xtmpl", "Entries", "Repository", "Root" )
}
I have some modules installed, can modules cause failures to the tests?
It seems to work, but ...
I should note that with this config:
$HTTP["host"] == "www.example.com" {
server.document-root = "/home/user/www.example.com/www"
accesslog.filename = "/home/user/www.example.com/logs/access_log"
fastcgi.server = ( ".php" =>
( "localhost" => ( "socket" => "/tmp/userphpfastcgi.socket", ) )
)
url.rewrite-if-not-file = (
"^/([^.?])\?(.)$" => "/index.php?q=$1&$2",
"^/([^.?])$" => "/index.php?q=$1",
"([a-zA-Z-.\/\?\=\&])" => "/index.php"
)
url.access-deny = ( "~", ".engine", ".inc", ".info", ".install", ".module",
".profile", ".test", ".po", ".sh", ".sql ", ".mysql", ".theme",
".tpl", ".xtmpl", "Entries", "Repository", "Root" )
}
If I go to www.example.com/node/1 in my browser, it seems to work. So I know rewriting is happening. However, this is apparently not good enough to pass the Clean URLs test. Is there really no documentation on what those tests are?
Everyone, please note that
Everyone, please note that the input filters seem to be mangling many of the config files posted above - specifically, asterisks in regular expressions are causing things to be italicized instead of just appearing as asterisks. Copy-and-pasting that code is going to result in problems. Those who want to share code should re-post it using the "Filtered HTML -- No Markdown" input format until this problem is fixed.
The Boise Drupal Guy!
Lighttp on drupal
Correct way to work clean URL
More clearly ...
Clean url solution - https://github.com/nilanjanray/drupal-light-http