我的网站上有这样一个地址:
在此示例中,查询字符串“gigaom.com”部分中的点破坏了 lighttpd 和我的重写规则。我得到带点的 404,如果我去掉点,则没有 404。我的重写规则如下。以防万一,我使用的是 symfony 1.4。
如果有人能阐明这个问题,我们将不胜感激!
url.rewrite-once = (
"^/(.*\..+)$" => "$0",
"^/(.*)\.(.*)" => "/index.php",
"^/([^.]+)$" => "/index.php/$1",
"^/$" => "/index.php"
)
对于任何遇到 lighttpd 和 symfony 问题的人(我知道你在那里,因为这个问题上有很多 Unresolved 线程)我最终在下面解决并回答了它。
最佳答案
好的,在以下工具的帮助下进行大量调试之后:
debug.log-request-handling = "enable"
^^ 当您尝试在 lighttpd 中调试重写规则时,这是一个救星! (它为我记录了一切到/var/log/lighttpd/error.log)
我想通了。对于所有无法让 symfony 与 lighttpd 一起工作的人(包括点问题!),这里有一组工作规则:
url.rewrite-once = (
"^/(js|images|uploads|css|sf)/(.*)" => "$0", # we want to load these assets as is, without index.php
"^/[a-zA-Z_-]+\.(html|txt|ico)$" => "$0", # for any static .html files you might be calling in your web root, we don't want to put the index.php controller in front of them
"^/sf[A-z]+Plugin.*" => "$0", # don't want to mess with plugin routes
"^/([a-z_]+)\.php(.*)\.(.*)$" => "/$1.php$2.$3", # same concept as rules below, except for other applications/environments (backend.php, backend_dev.php, etc)
"^/([a-z_]+)\.php([^.]*)$" => "/$1.php$2", # see comment right above this one
"^/(.*)\.(.*)$" => "/index.php/$1.$2", # handle query strings and the dot problem!
"^/([^.]+)$" => "/index.php/$1", # general requests
"^/$" => "/index.php" # the home page
)
如果有人有更多问题,请在这里发帖。谢谢!
关于mod-rewrite - Lighttpd 配置,. (点)在我的查询字符串中导致 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3965651/