.htaccess 与 PHP http_redirect() 中的 301 重定向
在 .htaccess 文件中设置 301 重定向与调用 PHP http_redirect() 在 SEO、性能或其他方面有什么区别吗?
Is there any difference, with respect to SEO, performance, or otherwise, in setting 301 redirects in a .htaccess file vs calling PHPs http_redirect()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 .htacess 方法可以防止调用 PHP,这在技术上更快。有时有人说 SEO 会受到响应时间的影响,这可能是一个好处。
除此之外,网络服务器通常有更好的重定向过程实施,这通常受到 SEO 的尊重 - 如果不是这样,那么你的潜在网站用户也会尊重这一点。
如果您正在寻找更好的 PHP 实现,请参阅
http_redirect
。Using the .htacess method prevents PHP being invoked which is technically faster. As it's sometimes said that SEO is influenced by response time, this can be a benefit.
Next to that webservers most often have a better implementation of the redirect procedure which is often honoured by SEO - and if not that, then by your potential site users.
If you're looking for a better implementation in PHP, see
http_redirect
.从技术上讲没有区别。来自服务器的响应将是相同的。
另外,我想说性能没有差异,或者说它无法真正衡量。
无论哪种情况,服务器都必须打开一个文件(.htaccess 或 .php),然后进行重定向。我不确定加载 php 处理器是否会产生明显的差异。也许如果该网站每秒受到数千个请求的打击。 ;)
Technically there is no difference. The response from the server would be the same.
Also, I'd say that there's no difference in performance, or that it's not really measureable.
In either case, the server has to open a file (either .htaccess or .php) and would then redirect. I'm unsure, if loading the php processor would make a noticeable difference. Maybe if the site is hammered by thousands of requests per second. ;)