406服务器错误 [英] 406 Server Error

查看:479
本文介绍了406服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,该网站的工作无差错在我们本地机器和我们的测试服务器也。然而,当我们把它活服务器上的网站,我们得到406错误,随机存在的。

I have a website which works error free on our local machine and also on our test server. However when we put it on the live server the website we get 406 errors randomly occuring.

例如,如果我们访问website.com/clothes或website.com/clothes/tshirts页面加载罚款和图像显示正确无误。如果我们定位到website.com/clothes/tshirts/bluepinned~~V的产品形象(website.com/images/clothes/tshirts/bluepinned.jpg)无法加载萤火虫给一个406错误。如果我们缓存刷新页面(Ctrl + F5)所有的网页资源(如样式表,图像等),产生一个406错误,如果你再次刷新了整个服务器似乎超时,什么也不显示。如果我重新启动我的路由器(给我一个新的IP地址),我可以再次访问该网站。

Example, if we visit website.com/clothes or website.com/clothes/tshirts pages load fine and images display correctly without error. If we navigate to website.com/clothes/tshirts/bluepinned the product image (website.com/images/clothes/tshirts/bluepinned.jpg) fails to load giving a 406 error in firebug. If we cache refreshed the page (CTRL + F5) all of the pages resources (like stylesheets, images etc.) produce a 406 error and if you refresh again the whole server seems to time out and nothing is displayed. If I reboot my router (giving me a new IP address) I can visit the site again.

网址:

website.com/clothes <- category showing all sub-categories and products (using product thumb image)
website.com/clothes/tshirts <- sub-category showing all products (using product thumb image)
website.com/clothes/tshirts/bluepinned <- individual product page (using large product image)

的.htaccess:

.htaccess:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(clothes)/([^/\.]+)/([^/\.]+)/?$ products.php?c=$1&sc=$2&p=$3 [NC,L,QSA] 
RewriteRule ^(clothes)/([^/\.]+)/?$ products.php?c=$1&sc=$2 [NC,L,QSA] 
RewriteRule ^(clothes)/?$ products.php?c=$1 [NC,L,QSA] 

我检查的phpinfo - 没有mod_security的发现。没有什么特别的加载这些网页上 - 用PHP类调用基本的HTML页面加载类别/子catagory /产品。有没有JavaScript或POST或AJAX。

I checked phpinfo - no mod_security found. There's nothing special on those pages that are loading - basic HTML page with PHP class call to load category/sub-catagory/products. There's no Javascript or POST or AJAX.

任何想法可能会导致406?

Any ideas what might be causing the 406?

更新1: 这是萤火虫/火狐(除去主机和推荐人)头的响应:

Update 1: This is the header response in Firebug/Firefox (removed Host and Referrer):

Response Headers:
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection  Keep-Alive
Content-Type    text/html
Date    Thu, 23 Aug 2012 05:36:54 GMT
Expires Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive  timeout=5, max=99
Pragma  no-cache
Server  Apache
Transfer-Encoding   chunked
X-Powered-By    PHP/5.2.17

Request Headers:
Accept  image/png,image/*;q=0.8,*/*;q=0.5
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection  keep-alive
Cookie  __utma=175298877.1838807483.1343995016.1345683454.1345698456.35; __utmz=175298877.1344487166.16.3.utmcsr=google.com|utmccn=(referral)|utmcmd=referral|utmcct=/imgres; __utmc=175298877; PHPSESSID=0d6664f0306618ac0f4218895efc4404; __utmb=175298877.2.10.1345698456
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1

更新2: 在谷歌浏览器标题回应:

Update 2: Header response in Google Chrome:

Request Method:GET
Status Code:406 Not Acceptable

Request Headers
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:PHPSESSID=d5b28960a6d3e73c7db5a3808432ee71; __utma=175298877.1644911186.1345701704.1345701704.1345701704.1; __utmb=175298877.2.10.1345701704; __utmc=175298877; __utmz=175298877.1345701704.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1

Response Headers
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:text/html
Date:Thu, 23 Aug 2012 06:02:16 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=99
Pragma:no-cache
Server:Apache
Transfer-Encoding:chunked
X-Powered-By:PHP/5.2.17

更新3: 增加了当地的反应(即工作!)

Update 3: Added local response (that works!)

Response Headers
Accept-Ranges   bytes
Connection  Keep-Alive
Content-Length  28212
Content-Type    image/jpeg
Date    Thu, 23 Aug 2012 05:58:31 GMT
Etag    "40000000cd15a-6e34-4c6eb29ada7fc"
Keep-Alive  timeout=5, max=77
Last-Modified   Fri, 10 Aug 2012 15:40:25 GMT
Server  Apache/2.2.21 (Win64) mod_ssl/2.2.21 OpenSSL/1.0.0d PHP/5.3.8

Request Headers
Accept  image/png,image/*;q=0.8,*/*;q=0.5
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection  keep-alive
Cookie  PHPSESSID=mjete8dhhn9abi9fkdfkce0kh2
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1

所以,我会想象,如果该文件的.jpg,图像/ *会允许吗?

So I would imagine if the file is .jpg, image/* would allow it?

推荐答案

您必须使用 REQUEST_URI 而不是 REQUEST_FILENAME 或追加了localPath你重写规则

you must use REQUEST_URI instead of REQUEST_FILENAME or append the localpath to your rewrite rules

从Apache DOC的:

from the apache doc's:

REQUEST_URI

请求的URI的路径成分,如   /index.html。这主要是排除了是查询字符串   可作为为名为QUERY_STRING其自己的变量。

The path component of the requested URI, such as "/index.html". This notably excludes the query string which is available as as its own variable named QUERY_STRING.

REQUEST_FILENAME

完整的本地文件系统中的文件路径或脚本匹配    请求,如果这已经由服务器时确定    REQUEST_FILENAME被引用。否则,如在使用时    虚拟主机的背景下,相同的值REQUEST_URI

The full local filesystem path to the file or script matching the request, if this has already been determined by the server at the time REQUEST_FILENAME is referenced. Otherwise, such as when used in virtual host context, the same value as REQUEST_URI.

也结账 LogLevel的警报改写:TRACE3 对于什么是取代了明确的strace的,什么是matchd

also checkout LogLevel alert rewrite:trace3 for a clear strace of what is replaced and what is matchd

这篇关于406服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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