1

我有一个带有 fastcgi 和 web.py 的 lighttpd 服务器,具有以下 fcgi 配置:

fastcgi.server = ( "/code.py" => 
(( "socket" => "/tmp/fastcgi.socket",
   "bin-path" => "/etc/lighttpd/code/code.py",
   "check-local" => "disable",
   "max-procs" => 1

)))

和主要配置:

url.rewrite-once = (
  "^(.*)/favicon.ico$"  => "/static/favicon.ico",
  "^/static/(.*)$"      => "/static/$1",
  "^/code.py(.*)$"      => "/code.py/404",
  "^/forum(.*)$"        => "/code.py/forum/$1"
)

如果我去 www.mysite.com/forum 一切正常,但如果我去 www.mysite.com/code.py/forum 我不会像我应该的那样重定向到 404,但实际上获取第一个链接。我基本上想向外界隐藏我的内部。

我查看了错误日志,似乎服务器确实在重写 url,但并没有什么不同。

(response.c.300) -- splitting Request-URI 
(response.c.301) Request-URI  :  /code.py/forum 
(response.c.302) URI-scheme   :  https 
(response.c.303) URI-authority:  www.mysite.com 
(response.c.304) URI-path     :  /code.py/forum 
(response.c.305) URI-query    :   
(response.c.300) -- splitting Request-URI 
(response.c.301) Request-URI  :  /code.py/404 
(response.c.302) URI-scheme   :  https 
(response.c.303) URI-authority:  www.mysite.com 
(response.c.304) URI-path     :  /code.py/404 
(response.c.305) URI-query    :   
(response.c.349) -- sanatising URI 
(response.c.350) URI-path     :  /code.py/404 
(mod_access.c.135) -- mod_access_uri_handler called 
(mod_fastcgi.c.3609) handling it in mod_fastcgi 
(response.c.470) -- before doc_root 
(response.c.471) Doc-Root     : /var/www/html 
(response.c.472) Rel-Path     : /code.py 
(response.c.473) Path         :  
(response.c.521) -- after doc_root 
(response.c.522) Doc-Root     : /var/www/html 
(response.c.523) Rel-Path     : /code.py 
(response.c.524) Path         : /var/www/html/code.py 
(response.c.541) -- logical -> physical 
(response.c.542) Doc-Root     : /var/www/html 
(response.c.543) Rel-Path     : /code.py 
(response.c.544) Path         : /var/www/html/code.py 
(mod_fastcgi.c.3035) got proc: pid: 30262 socket: unix:/tmp/fastcgi.socket-0 load: 1 

有任何想法吗?

4

1 回答 1

1

尝试这样的事情:

url.rewrite-once = (
  "^/favicon\.ico$" => "/static/favicon.ico",
  "^/forum(.*)$" => "/forum/code.py$1"
)

$HTTP["url"] =~ "^/forum(.*)$" { 
  ( "/code.py" => 
    (( "socket" => "/tmp/fastcgi.socket",
       "bin-path" => "/etc/lighttpd/code/code.py",
       "check-local" => "disable",
       "max-procs" => 1,
       "bin-environment" => ("REAL_SCRIPT_NAME" => "")
    ))
  )
}
于 2012-10-28T14:11:49.830 回答