301重定向在WordPress页面上等待时间较长

huangapple go评论61阅读模式
英文:

Long waiting time in 301 redirect on WordPress pages

问题

我有一个WordPress网站,GTMetrix分析如下:

https://gtmetrix.com/reports/www.insil.com.au/NrpADawD/

在此输入图像描述

请求的等待时间几乎达到了600毫秒,而在其他尝试中,仅仅是为了添加斜杠,就达到了1.5秒。

我尝试添加重定向301 /build-a-website /build-a-website/ 但它导致了一个重定向循环。有没有办法减少等待时间或找出它的原因?

英文:

I have a WordPress website and the GTMetrix analysis is as below:

https://gtmetrix.com/reports/www.insil.com.au/NrpADawD/

enter image description here

The waiting time of the request is almost 600ms and in other attempts it reached 1.5 seconds just to add trailing slash.

I tried add Redirect 301 /build-a-website /build-a-website/ but it caused a loop redirect. Any idea how to reduce the waiting time or identify the cause of it?

答案1

得分: 0

如果是WordPress在添加尾部斜杠,WordPress核心和插件可能已加载,并且这会减慢重定向时间。一些主机提供用于管理重定向的界面,可以提供最高性能。

一般来说,使用htaccess进行重定向也可能会对性能造成影响,所以请注意这一点。

对于您明确的重定向,请尝试将其更改为以下内容:

Redirect 301 ^/build-a-website$ /build-a-website/

插入符号^指定字符串的开头,而美元符号$指定字符串的结尾。这意味着/build-a-website/将不再与/build-a-website匹配,因为明确指示websitee是URL的最后一个字符。

英文:

If it's WordPress that's adding the trailing slash, WordPress core and plugins may be loaded, and that's what slows down the redirect time. Some hosts have an interface for managing redirects, that give you the highest performance possible.

In general, using htaccess for redirects can also cause a performance impact, so be aware of that.

For your explicit redirect, try changing it to this:

Redirect 301 ^/build-a-website$ /build-a-website/

The caret ^ specifies the beginning of the string, and the dollar $ specifies the end of the string. This means that /build-a-website/ will no longer match to /build-a-website because it is explicitly indicated that the e of website is the last character of the URL.

huangapple
  • 本文由 发表于 2023年6月5日 12:52:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76403562.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定