Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何nginx在location上下文中重写以下内容:
location
/=>/myurl/
/
/myurl/
/abc/=>/myurl/abc/
/abc/
/myurl/abc/
以下将做的伎俩:
location / { rewrite ^ /myurl/$uri; }
请注意,/abc/ 将匹配 / 前缀(并被重写为 /myurl/abc/),因此不需要单独重写
另请注意,您需要添加一个额外的“location /myurl/ {...}”块以避免收到对该 url 的传入请求以重写为 /myurl/myurl/... 等等
看起来这样可以解决问题:
rewrite ^(/.*)$ ^/admin/$1 break;
还有什么建议吗?