V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
mrco
V2EX  ›  NGINX

请教一个 nginx 的 rewrite 写法。

  •  
  •   mrco · Apr 30, 2021 · 2514 views
    This topic created in 1835 days ago, the information mentioned may be changed or developed.

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

    感谢~~~

    6 replies    2021-04-30 14:36:36 +08:00
    zzl22100048
        1
    zzl22100048  
       Apr 30, 2021
    不能用 proxy_pass 处理吗
    AoEiuV020
        2
    AoEiuV020  
       Apr 30, 2021
    rewrite ^/post/(.*) http://ai.city.cn/$1 permanent;
    dier
        3
    dier  
       Apr 30, 2021
    试试这个?
    ```
    server_name x.city.cn;
    location / {
    root html;
    }
    location /post/ {
    rewrite ^/post/(.*)$ http://ai.city.cn/$1;
    }
    ```
    mrco
        4
    mrco  
    OP
       Apr 30, 2021
    @AoEiuV020 谢谢亲~
    mrco
        5
    mrco  
    OP
       Apr 30, 2021
    @dier 谢谢亲~~~~
    qdporter
        6
    qdporter  
       Apr 30, 2021
    location ^~ /post {
    proxy_pass ai.city.cn/
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2876 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 02:30 · PVG 10:30 · LAX 19:30 · JFK 22:30
    ♥ Do have faith in what you're doing.