Apache rewrite rule to lighttpd

2019-08-10 11:36发布

How to convert this apache rewrite rule to lighttpd rewrite rule?

# 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条回答
放我归山
2楼-- · 2019-08-10 12:19

Try

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"
    #)

}

Hope that helps.

查看更多
登录 后发表回答