通过许多查询字符串参数美化URL

时间:2019-09-18 17:12:19

标签: nginx url-rewriting

我们有一些看起来像这样的URL

http://example.com/path/file.html?fruit=banana&table=true&room=kitchen

我们通常只修改水果。我想通过类似的方式使它可访问

http://example.com/banana/

我目前正在尝试使用proxy_pass来完成此操作,就像这样:

server {
    listen      80;
    server_name example.com;
    location = /banana/ {
        proxy_pass http://example.com/path/file.html?fruit=banana&table=true&room=kitchen
    }
}

问题是JavaScript依赖于查询字符串来获取值,但是它不再存在。

我看过rewrite,但是我从未使用过它,所以还不太清楚如何使它工作。我基本上想要的是与these questions完全相反的东西。

有可能吗?

0 个答案:

没有答案