简化 nginx 上的重写规则
simplify a rewrite rule on nginx
我想简化那些重写规则,不知道这是否可行,这是我所做的:
rewrite ^/en/m/(.*)/$ /index.php?lang=en&cat=&platform=mobile last;
rewrite ^/en/(.*)/$ /index.php?lang=en&cat= last;
rewrite ^/m/(.*)/$ /index.php?cat=&platform=mobile last;
rewrite ^/(.*)/$ /index.php?cat= last;
它有效,但重写规则的数量相当大..
参数 /m/(对于移动设备)是可选的,有没有办法简化它?有什么想法吗?
我终于传递了一个参数并使用 php 对其进行了解析,效果非常好,谢谢 Alexey!:)
我想简化那些重写规则,不知道这是否可行,这是我所做的:
rewrite ^/en/m/(.*)/$ /index.php?lang=en&cat=&platform=mobile last;
rewrite ^/en/(.*)/$ /index.php?lang=en&cat= last;
rewrite ^/m/(.*)/$ /index.php?cat=&platform=mobile last;
rewrite ^/(.*)/$ /index.php?cat= last;
它有效,但重写规则的数量相当大..
参数 /m/(对于移动设备)是可选的,有没有办法简化它?有什么想法吗?
我终于传递了一个参数并使用 php 对其进行了解析,效果非常好,谢谢 Alexey!:)