NGINX - 返回 301 与重写 [英] NGINX - Return 301 vs Rewrite

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

问题描述

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

I use NGINX in my dedicated server.

我有一个关于返回重写 301 的问题.

I've a question about the return and rewrite 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?

推荐答案

nginx 陷阱 你应该使用服务器块和 return 语句,因为它们比通过 location 块评估 RegEx 快得多.

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,因此在 SEO 方面没有区别,顺便说一句..

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

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

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