英文:
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/
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
匹配,因为明确指示website
的e
是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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论