0

我需要帮助,我正在将规则从 lighthttpd 重写为 apache httpd。虽然我以前从未使用过 lighthttpd。我希望有人可以帮助我重写这段代码。即使在 apache 中,我也对 Rule 系统有点失望,但还不错。

"^install/?$" => "install.php",

"^/doc/([a-z]+)/?$" => "doc.php?cat=$1",
"^/~([a-z.]+)/doc/([a-z]+)/?$" => "doc.php?project=$1&cat=$2",

"^/~([a-z.]+)/?$" => "index.php?project=$1",
"^/~([a-z.]+)/api/([a-z]+)/?$" => "index.php?project=$1&mode=$2",

"^/all/?$" => "list.php",
"^/api/([a-z]+)/all/?$" => "list.php?mode=$1",
"^/~([a-z.]+)/all/?$" => "list.php?project=$1",
"^/~([a-z.]+)/api/([a-z]+)/all/?$" => "list.php?project=$1&mode=$2",
"^/rss/?$" => "list.php?rss=1",
"^/~([a-z.]+)/rss/?$" => "list.php?project=$1&rss=1",
"^/all/([0-9]+)/?$" => "list.php?page=$1",
"^/api/([a-z]+)/all/([0-9]+)/?$" => "list.php?mode=$1&page=$2",
"^/~([a-z.]+)/all/([0-9]+)/?$" => "list.php?project=$1&page=$2",
"^/~([a-z.]+)/api/([a-z]+)/all/([0-9]+)/?$" => "list.php?project=$1&mode=$2&page=$3",

"^/([0-9]+)/?$" => "show.php?id=$1",
"^/~([a-z.]+)/([0-9]+)/?$" => "show.php?project=$1&id=$2",
"^/([0-9]+)/([a-z|A-Z]+)/?$" => "show.php?id=$1&mode=$2",
"^/~([a-z.]+)/([0-9]+)/([a-z|A-Z]+)/?$" => "show.php?project=$1&id=$2&mode=$3",
"^/api/([a-z|A-Z]+)/([0-9]+)/?$" => "show.php?mode=$1&id=$2",
"^/~([a-z.]+)/api/([a-z|A-Z]+)/([0-9]+)/?$" => "show.php?project=$1&mode=$2&id=$3",
"^/([0-9]+)/([0-9]+)/?$" => "show.php?id=$1&hash=$2",
"^/~([a-z.]+)/([0-9]+)/([0-9]+)/?$" => "show.php?project=$1&id=$2&hash=$3",
"^/([0-9]+)/([0-9]+)/([a-z|A-Z]+)/?$" =/> "show.php?id=$1&hash=$2&mode=$3",
"^/~([a-z.]+)/([0-9]+)/([0-9]+)/([a-z|A-Z]+)/?$" => "show.php?project=$1&id=$2&hash=$3&mode=$4",
"^/api/([a-z|A-Z]+)/([0-9]+)/([0-9]+)/?$" => "show.php?mode=$1&id=$2&hash=$3",
"^/~([a-z.]+)/api/([a-z|A-Z]+)/([0-9]+)/([0-9]+)/?$" => "show.php?project=$1&mode=$2&id=$3&hash=$4",
"^/api/([a-z|A-Z]+)/([0-9]+)/([0-9]+)/(.*)$" => "show.php?mode=$1&id=$2&hash=$3&password=$4",
"^/~([a-z.]+)/api/([a-z|A-Z]+)/([0-9]+)/([0-9]+)/(.*)$" => "show.php?project=$1&mode=$2&id=$3&hash=$4&password=$5"

我唯一转换的是第一行

RewriteRule ^install/.* install.php
4

1 回答 1

0

所以

"^install/?$" => "install.php"

变成

RewriteRule ^install/?$ install.php [L]

"^/doc/([a-z]+)/?$" => "doc.php?cat=$1"

变成

RewriteRule ^doc/([a-z]+)/?$ doc.php?cat=$1 [L]

"^/~([a-z.]+)/doc/([a-z]+)/?$" => "doc.php?project=$1&cat=$2",

变成

RewriteRule ^~([a-z.]+)/doc/([a-z]+)/?$ doc.php?project=$1&cat=$2 [L]

"^/~([a-z.]+)/?$" => "index.php?project=$1",

变成

RewriteRule ^~([a-z.]+)/?$ index.php?project=$1 [L]

等等

于 2013-04-23T10:34:00.400 回答