apache - NGINX / Apache 重写规则
问题描述
我需要一些 NGINX / Apache 的重写规则(目前正在使用 NGINX,但取决于我的老板,它可能稍后会更改为 Apache)。
规则应该使服务器解释 URL 如下:
https://domain.tld/signin
https://domain.tld/hello/world
https://domain.tld/user/john/doe
像这样:
https://domain.tld/index.php?lvl1=signin
https://domain.tld/index.php?lvl1=hello&lvl2=world
https://domain.tld/index.php?lvl1=user&lvl2=john&lvl3=doe
(或类似的东西,它不一定是 lvl1、lvl2、lvl3 ......但我可以使用的东西)。
我也面临两个问题:
- 应排除在域之后直接以 a 开头的文件路径
/static/
,以便在 HTML 文件中正确传递链接的 CSS、JS、PDF、图像、视频...。 - 常规 GET 参数应该仍然可以正常工作,就好像它们没有被触及一样。类似的 URL
/foo/bar?action=edit
仍应解释为/lvl1=foo&lvl2=bar&action=edit
有没有人可以帮助我处理 NGINX 和 Apache 的这些规则?我已经搜索了很长时间,但没有找到令人满意的解决方案。
解决方案
推荐阅读
- docker - Kubernetes:端口转发后,我可以通过“localhost”访问服务,但不能通过“hostname”访问
- python - 跨多个模块使用外观模式时如何避免循环依赖
- c# - System.Text.Json.JsonDocument.Parse 对象数组
- vue.js - VUEX - 在同一页面上具有相同动作名称的许多 mapAction
- swift - 由于 macOS Catalina Xcode 应用程序每晚都会因 CVCGDisplayLink 异常而崩溃
- python - 错误:只有 size-1 的数组可以转换为 Python 标量
- python-3.x - Python如何选择单选按钮
- vb.net - 从 Blob 字段创建 pdf
- actor - 在 ray.io 中存储和检索对象
- java - Java、ehCache 和 timeToIdleExpiration