如何在nginx中的重写规则中隐藏页面名称
我正在尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
位置
仅匹配单个URL/
,重写
语句仅匹配以/refere>/referaL/referal/referal/
开头的URL 。如果您需要匹配仅包含数字的URL,则可以使用:
您可以将其放置在
Server
block或现有location> location/
block中。location = /< /code>块将不起作用。
Your
location
only matches the single URL/
, and therewrite
statement only matches URLs that begin with/referal/
.If you need to match URLs that contain only digits, you could use:
You can place this in the
server
block, or the existinglocation /
block. Thelocation = /
block will not work.