【问题标题】:Proper way to 301 redirect using Nginx使用 Nginx 进行 301 重定向的正确方法
【发布时间】:2016-10-06 07:47:38
【问题描述】:

我使用 Nginx 作为网络服务器。我需要按照以下模式 301 重定向 url

adomain.com/detail.php?name=eC-F_VZ2T1c

进入

adomain.com/watch?v=eC-F_VZ2T1c

试过这个sn-p

location /detail.php {
    if ($arg_name) {
        return 301 http://adomain.com/watch?v=$arg_name;
    }
}

没有成功!

我做错了什么?

【问题讨论】:

    标签: php http redirect nginx http-status-code-301


    【解决方案1】:

    rewrite 可能会给您带来更好的运气 - 尝试将您的退货行替换为以下内容:

    rewrite ^ http://adomain.com/watch?v=$arg_name permanent;
    

    permanent 标志表示永久 301 重定向。

    根据在以下位置找到的文档:

    http://nginx.org/en/docs/http/ngx_http_rewrite_module.html

    【讨论】:

    • invalid parameter "permament"
    • hmm,你用的是什么版本的nginx和安装包?
    • 我认为他们可能正在使用 mgimx
    猜你喜欢
    • 2016-07-25
    • 2011-01-20
    • 2015-09-16
    • 2018-12-13
    • 2018-07-30
    • 1970-01-01
    • 2018-05-18
    • 1970-01-01
    相关资源
    最近更新 更多