V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
mrco
V2EX  ›  NGINX

请教一个 nginx 的 rewrite 写法。

  •  
  •   mrco · 2021-04-30 14:00:57 +08:00 · 1615 次点击
    这是一个创建于 1064 天前的主题,其中的信息可能已经有所发展或是发生改变。

    x.city.cn/post/???? 到  ai.city.cn/???? 的 url rewrite 。

    感谢~~~

    6 条回复    2021-04-30 14:36:36 +08:00
    zzl22100048
        1
    zzl22100048  
       2021-04-30 14:18:14 +08:00
    不能用 proxy_pass 处理吗
    AoEiuV020
        2
    AoEiuV020  
       2021-04-30 14:25:07 +08:00
    rewrite ^/post/(.*) http://ai.city.cn/$1 permanent;
    dier
        3
    dier  
       2021-04-30 14:25:14 +08:00
    试试这个?
    ```
    server_name x.city.cn;
    location / {
    root html;
    }
    location /post/ {
    rewrite ^/post/(.*)$ http://ai.city.cn/$1;
    }
    ```
    mrco
        4
    mrco  
    OP
       2021-04-30 14:26:47 +08:00
    @AoEiuV020 谢谢亲~
    mrco
        5
    mrco  
    OP
       2021-04-30 14:26:56 +08:00
    @dier 谢谢亲~~~~
    jiurenbudai
        6
    jiurenbudai  
       2021-04-30 14:36:36 +08:00
    location ^~ /post {
    proxy_pass ai.city.cn/
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2703 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:10 · PVG 23:10 · LAX 08:10 · JFK 11:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.