Different lighttpd rewrite rules in subirectory

前端 未结 1 1069
梦毁少年i
梦毁少年i 2021-01-19 22:28

I\'m having a few issues getting rewrite rules for a specific subdirectroy (different from the webroot) and I\'m at a loss as to where to put them.

/var/www/ (webroo

相关标签:
1条回答
  • 2021-01-19 23:25

    I am not quite sure what you want to express - I will explain what your current ruleset does.

    do not use this, user rewrite-once instead

    url.rewrite = (
    

    you keep map any index.php and test.php (even foo-test.php) back to the webroot

    "(index.php|test.php|favicon.ico)" => "/$1",
    

    you rewrite any subfolder or files containing css,files,tmp or js in it's url back to the webroot

    "(css|files|img|js)/(.*)" => "/$1/$2",
    

    now this matches anything in the your webroot (no subdirs!) and keeps get requests

    "^([^\?]*)(\?(.+))?$" => "/index.php?url=$1&$3",
    )
    

    Update This should do it (untested)

    url.rewrite-once = (
    "^/subdir/(?:index.php|test.php|favicon.ico)" => "$0",
    "^/subdir/(?:.+/)?(css|files|img|js)/(.*)" => "/subdir/$1/$2", #update #2
    "^/subdir/(?:/(?:.+/))?([^\?]*)(?:\?(.+))?$" => "/subdir/index.php?url=$1&$2",
    
    "^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
    "^/(.*.php)" => "$0",
    "^/(.*)$" => "/index.php/$1"
    )
    
    0 讨论(0)
提交回复
热议问题