lighttpd 中的 URL 重写

发布于 2024-09-27 08:22:56 字数 508 浏览 0 评论 0原文

我有以下查询:

update234ae5.php?q=1&q=2....

必须重写为:

update.php?cond=234ae5&q=1&q=2....

我使用:

"^/update(([a-zA-Z0-9]+))"  =>  "/update.php?cond=$1"

如何添加其余的 url 字符串,因为我的 url 被重写为

update.php?cond=234ae5& 

没有其余的参数

在 Apache 中我使用

RewriteCond %{QUERY_STRING} (.*)  
RewriteRule ^/update([0-9a-z]+).php /update.php?cond=$1&%1

I have the following query:

update234ae5.php?q=1&q=2....

must be rewritten to:

update.php?cond=234ae5&q=1&q=2....

I use:

"^/update(([a-zA-Z0-9]+))"  =>  "/update.php?cond=$1"

How can I add the rest of url string, because my url is rewritten to

update.php?cond=234ae5& 

without the rest of params

In Apache I use

RewriteCond %{QUERY_STRING} (.*)  
RewriteRule ^/update([0-9a-z]+).php /update.php?cond=$1&%1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

向地狱狂奔 2024-10-04 08:22:56

正如 lighttpd 文档所述

如果你想传递查询字符串
(?foo=bar) 到重写目的地
你必须明确匹配它:

所以你会想要类似的东西:

"^/update([a-zA-Z0-9]+)\.php(\?(.+))?" => "/update.php?cond=$1&$3"

As the lighttpd documentation states:

If you wanna pass the Query String
(?foo=bar) to the rewrite destination
you have to explicitly match it:

So you'll want something like:

"^/update([a-zA-Z0-9]+)\.php(\?(.+))?" => "/update.php?cond=$1&$3"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文