我在看一篇文章referenced by Jeff Atwood关于 Yahoo's "Best Practices" for speeding up a website ,我注意到了这个小 gem :
One of the most wasteful redirects happens frequently and web developers are generally not aware of it. It occurs when a trailing slash (/) is missing from a URL that should otherwise have one. For example, going to http://astrology.yahoo.com/astrology results in a 301 response containing a redirect to http://astrology.yahoo.com/astrology/ (notice the added trailing slash). This is fixed in Apache by using Alias or mod_rewrite, or the DirectorySlash directive if you're using Apache handlers.
这还会发生吗?随着网络的发展,这篇文章已经很老了。我想我多年来一直在这样做。我想我最近没有注意到这种情况发生,但话说回来,我从来没有真正看过。这是 Apache 的东西吗? IIS 7 会这样做吗?
我很害怕。抱着我。
最佳答案
尝试一下!
以下是一些从终端运行的截断请求。
curl -I http://astrology.yahoo.com/astrology
HTTP/1.0 301 Moved Permanently
Date: Tue, 21 Jun 2011 13:24:24 GMT
Location: http://shine.yahoo.com/astrology/
curl -I http://wordpress.org/extend
HTTP/1.0 301 Moved Permanently
Server: nginx
Date: Tue, 21 Jun 2011 13:26:17 GMT
Location: http://wordpress.org/extend/
尽管 IIS 似乎以另一种方式做到了:
curl -I http://www.iis.net/overview
HTTP/1.0 200 OK
Server: Microsoft-IIS/7.0
curl -I http://www.iis.net/overview/
HTTP/1.0 301 Moved Permanently
Location: http://www.iis.net/overview
猜猜这取决于您如何配置它,但这绝对是需要优化的东西。
关于performance - 目录斜杠重定向?这还会发生吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6425929/