0

希望有人可以帮助我,我试图强制 nginx 配置在到达 url 时显示特定文件,例如:

/contact 使用contact.php

/shop?something=x 使用 shop.php

/shop/xxxxx 使用 category.php

/shop/sale/xxxx?something=x 使用 product.php

/tienda/xxxxx 使用 categoria.php

感谢任何帮助

4

1 回答 1

0

/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 重写会变得非常难以快速维护。

于 2018-07-05T20:08:17.940 回答