NGINX-Return 301与Rewrite [英] NGINX - Return 301 vs Rewrite

查看:218
本文介绍了NGINX-Return 301与Rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在专用服务器中使用 NGINX .

I use NGINX in my dedicated server.

我对返回重写301 有疑问.

重写301:

rewrite ^ http://xxx.xxxxx.net/xx-xxx/$request_uri? permanent;

返回301:

location ~ redirect-this/?$ {
    return 301 http://xxx.xxxxx.net/xx-xxx/redirect-this$1;
}


所有重定向均正常工作.但是..


All redirects work correctly. But..

哪种方法最有效地进行301重定向?

我有200多个网址要重定向.那么,您有什么建议?

I've more than 200 url to redirect. So, what you recommend?

推荐答案

As stated in the nginx pitfalls you should use server blocks and return statements as they're way faster than evaluating RegEx via location blocks.

由于您要强制重写规则发送301,因此搜索引擎优化没有什么区别,顺便说一句.

Since you're forcing the rewrite rule to send a 301 there's no difference when it comes to SEO, btw..

这篇关于NGINX-Return 301与Rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆