Apache RewriteCond 到 Lighttpd
我想将一些在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您列出的 Apache 规则使用 RewriteCond 接受任何请求不会转到目录 (!-d),也不会转到文件 (!-f) 并重定向它以将 URL 数据作为参数“url”传递到 index.php。它确保保留任何其他 CGI 参数 (QSA),并且如果此规则匹配 (L),则不会再匹配任何规则。
因此
http://yourserver.org/something-silly
将转到http://yourserver.org/index.ph?url=something-silly
和http://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 tohttp://yourserver.org/index.ph?url=something-silly
andhttp://yourserver.org/something-silly?q=search+terms
would go tohttp://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.