如何在nginx中的重写规则中隐藏页面名称

发布于 2025-02-09 16:40:08 字数 289 浏览 2 评论 0原文

我正在尝试使用nginx中的重写规则从URL隐藏页面名称。但是它不起作用,请参阅以下示例

实际URL:https://super30.net/referal.php?uid=999999所需的URL:https://super30.net/9999999

我尝试了以下代码

location = / {
      rewrite ^/referal/(.*)$ /referal.php?uid=$1 last;
    }

I am trying to hide page name from url using rewrite rules in Nginx. but its not working, please see the below example

Actual url: https://super30.net/referal.php?uid=999999 Needed url: https://super30.net/999999

I tried below code

location = / {
      rewrite ^/referal/(.*)$ /referal.php?uid=$1 last;
    }

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

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

发布评论

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

评论(1

吃颗糖壮壮胆 2025-02-16 16:40:08

您的位置仅匹配单个URL /重写语句仅匹配以/refere>/referaL/referal/referal/开头的URL 。

如果您需要匹配仅包含数字的URL,则可以使用:

rewrite ^/(\d+)$ /referal.php?uid=$1 last;

您可以将其放置在Server block或现有location> location/ block中。 location = /< /code>块将不起作用。

Your location only matches the single URL /, and the rewrite statement only matches URLs that begin with /referal/.

If you need to match URLs that contain only digits, you could use:

rewrite ^/(\d+)$ /referal.php?uid=$1 last;

You can place this in the server block, or the existing location / block. The location = / block will not work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文