Apache 重写到 Nginx 重写

发布于 2024-12-23 09:01:40 字数 356 浏览 1 评论 0原文

我有以下 apache 重写规则:

RewriteEngine On
RewriteRule ^id/([^/\.]+)$ item.php?id=$1 [L]

并且我需要能够将它与 Nginx 一起使用。其目的是让某人可以访问 http://mysite.com/id/10必须去 http://mysite.com/item.php?id=10。 谁能帮我转换一下吗?

提前致谢!

I have the following apache rewrite rule:

RewriteEngine On
RewriteRule ^id/([^/\.]+)$ item.php?id=$1 [L]

and I need to be able to use it with Nginx. It is meant to so that someone can go to http://mysite.com/id/10 and instead of having to be go http://mysite.com/item.php?id=10.
Can anyone help me convert it?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

随梦而飞# 2024-12-30 09:01:40

你的意思是这样的:

rewrite ^/id/([0-9]+)/?$ /item.php?id=$1 last;

you mean like this:

rewrite ^/id/([0-9]+)/?$ /item.php?id=$1 last;
夜雨飘雪 2024-12-30 09:01:40

这应该可以解决问题:

 rewrite ^/id/([^/\.]+)$ /item.php?id=$1 last;

This should do the trick:

 rewrite ^/id/([^/\.]+)$ /item.php?id=$1 last;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文