nginx php urls路径使用文件

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

/ contact使用contact.php </ p>

/ shop?something = x使用shop.php </ p>

/ shop / xxxxx使用category.php </ p>

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

/ tienda / xxxxx使用categoria .php </ p>

感谢任何帮助</ p>
</ div>

展开原文

原文

hope somebody can help me, Im trying to force nginx config to show specific files when the a url is reached, example:

/contact uses contact.php

/shop?something=x uses shop.php

/shop/xxxxx uses category.php

/shop/sale/xxxx?something=x uses product.php

/tienda/xxxxx uses categoria.php

Appreciate any help

1个回答



/ shop / xxxxx使用category.php:</ p>

 重写^ / shop /  (。*)$ /category.php?category=$1 last; 
</ code> </ pre>

查看NGINX重写: https://www.nginx.com/blog/creating-nginx-rewrite-rules/ </ p>

同样,您可以查看: https:// www.thegeekstuff.com/2017/08/nginx-rewrite-examples/ </ p>

我强烈建议使用某种框架。 URL重写很难很快维护。</ p>
</ div>

展开原文

原文

/shop/xxxxx uses category.php:

rewrite ^/shop/(.*)$ /category.php?category=$1 last;

Check out NGINX rewriting: https://www.nginx.com/blog/creating-nginx-rewrite-rules/

As well, you can check out: https://www.thegeekstuff.com/2017/08/nginx-rewrite-examples/

I would highly recommend using some sort of framework. URL rewriting can become very hard to maintain really quickly.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐