› NGINX
› NGINX Trac
› 3rd Party Modules
› Security Advisories
› CHANGES
› OpenResty
› ngx_lua
› Tengine
在线学习资源
› NGINX 开发从入门到精通
NGINX Modules
› ngx_echo
Myflos
V2EX  ›  NGINX

求助:旧站搬迁新站 nginx301 规则怎么写

  •  
  •   Myflos · Oct 11, 2016 · 3110 views
    This topic created in 3676 days ago, the information mentioned may be changed or developed.

    题主要把网站域名由 a.com 换成 b.com ,更换完毕之后,访问目录不变; nginx 的 301 怎么写呀,求指点

    如:

    更换前: www.a.com/2015/beijing/ 更换后: www.b.com/2015/beijing/

    更换前: www.a.com/archiver/tid-103454.html 更换后: www.b.com/archiver/tid-103454.html

    5 replies  •  2016-10-11 20:33:41 +08:00
    SourceMan
    SourceMan
    Oct 11, 2016
    1
    server {
    listen 80;
    server_name a.com www.a.com;
    rewrite ^(.*) http://b.com$1 permanent;
    }
    Had
    Had
    PRO
    Oct 11, 2016
    2
    如果是 http

    return 301 http://www.b.com$request_uri;

    即可。
    Showfom
    Showfom
    PRO
    Oct 11, 2016 via iPhone
    3
    楼上两种方法都是可以的
    allenhu
    allenhu
    Oct 11, 2016 via Android
    4
    一搜就有的问题还要跑来发个帖
    abc123ccc
    abc123ccc
    Oct 11, 2016
    5
    答案集中,精确,最重要的是人家信赖 v2ex
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1295 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 21:12 · PVG 05:12 · LAX 13:12 · JFK 16:12
    ♥ Do have faith in what you're doing.