希望有人能帮助我,我正在尝试强制nginx config在到达url时显示特定的文件,例如:
/contact使用contact.php
/shop?something=x使用shop.php
/shop/xxxxx使用category.php
/shop/sale/xxxx?something=x使用product.php
/tienda/xxxxx使用categoria.php
感谢任何帮助
发布于 2018-07-05 20:08:18
/shop/xxxxx使用category.php:
rewrite ^/shop/(.*)$ /category.php?category=$1 last;
查看NGINX重写:https://www.nginx.com/blog/creating-nginx-rewrite-rules/
此外,您还可以查看:https://www.thegeekstuff.com/2017/08/nginx-rewrite-examples/
我强烈建议使用某种框架。URL重写可能会变得非常难以快速维护。
https://stackoverflow.com/questions/51198496
复制