Apache RewriteCond 到 Lighttpd

发布于 2024-08-15 01:22:25 字数 428 浏览 0 评论 0原文

我想将一些在 apache 上运行的站点迁移到 Lighttpd。

任何人都可以帮我将此重写规则转换为 Lighttpd 的等效规则:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

我正在阅读 Lighttpd 重写说明 (http://redmine.lighttpd.net/wiki/1/Docs:ModRewrite)但我不明白如何转换这个特定规则。

多谢

I want to migrate some sites running on apache to Lighttpd.

Can anyone help me to convert this Rewrite rule into a equivalent rule for Lighttpd:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

I'm reading the Lighttpd rewrite explanation (http://redmine.lighttpd.net/wiki/1/Docs:ModRewrite) but I didn't understand how convert this specific rule.

Thanks a lot

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

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

发布评论

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

评论(1

檐上三寸雪 2024-08-22 01:22:25

您列出的 Apache 规则使用 RewriteCond 接受任何请求不会转到目录 (!-d),也不会转到文件 (!-f) 并重定向它以将 URL 数据作为参数“url”传递到 index.php。它确保保留任何其他 CGI 参数 (QSA),并且如果此规则匹配 (L),则不会再匹配任何规则。

因此 http://yourserver.org/something-silly 将转到http://yourserver.org/index.ph?url=something-sillyhttp://yourserver.org/ Something-silly?q=search+terms 将转到 http://yourserver.org/index.ph?url=something-silly&q=search-terms

Lighttpd 有 url.rewrite-if-not-file 部分实现了这一点,但如果是目录,它会重写 URL。因此,您必须添加规则以明确不重写转到已知有效目录的 URL。

The Apache rules you list use RewriteCond to take any request which doesn't go to a direcotyr (!-d) and which also doesn't go to a file (!-f) and redirects it to pass the URL data into index.php as parameter "url". It makes sure to preserve any other CGI arguments (QSA) and makes no further rules match if this rule matches (L).

So http://yourserver.org/something-silly would go to http://yourserver.org/index.ph?url=something-silly and http://yourserver.org/something-silly?q=search+terms would go to http://yourserver.org/index.ph?url=something-silly&q=search-terms

Lighttpd has url.rewrite-if-not-file which partially implements this, but it will rewrite URL if it's a directory. Therefore, you'll have to add rules to specifically NOT rewrite URLs that go to known valid directories.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文