Apache重写规则到lighttpd

时间:2012-03-08 06:58:29

标签: apache lighttpd

如何将此apache重写规则转换为lighttpd重写规则?

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /adpanel/

# Protect hidden files from being viewed
<Files .*>
 Order Deny,Allow
 Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

1 个答案:

答案 0 :(得分:1)

尝试

server.modules = (
    "mod_access",
    "mod_rewrite"
)

$HTTP["host"] == "example.com" {

    server.document-root = "/var/www/example.com/wwwroot/adpanel/"

    $HTTP["url"] =~ "^/application" {
            url.access-deny = ("")
    }

    $HTTP["url"] =~ "^/modules" {
            url.access-deny = ("")
    }

    $HTTP["url"] =~ "^/system" {
            url.access-deny = ("")
    }

    ## If later than lighttpd 1.4.24
    url.rewrite-if-not-file = (
        "^/(.*)$" => "/index.php/$1"
    )

    ## If older than 1.4.24 yo will have to reference actual files in the rewrite e.g.
    #url.rewrite = (
    #    "/(css|img|js|stats)/" => "$0",  ## $0 means the actual query string i.e don't rewrite.
    #    "^/(.*)$" => "/index.php/$1"
    #)

}

希望有所帮助。