Apache, CentOS, Kloxo and ogg mimetype



几个小时后试图解决问题,我想我疯了:S

我有一个ogg的声音在我的网站上工作良好的本地(Apache XAMPP),但它不工作在我的VPS (Apache, CentOs和Kloxo),即使在我的。htaccess我有所有的mimetypes(音频/ogg ogg)和(应用程序/ogg ogg)。

这是我在本地(工作)得到的标题:

Request URL:http://127.0.0.1/bass.ogg
Request Method:GET
Status Code:206 Partial Content
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:identity;q=1, *;q=0
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:PHPSESSID=08e4d19b19720f0a5491c20a7bba20c7
Host:127.0.0.1
Range:bytes=0-
Referer:http://127.0.0.1/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.160 Safari/537.22
Response Headersview source
Accept-Ranges:bytes
Cache-Control:max-age=2592000
Connection:Keep-Alive
Content-Length:59290
Content-Range:bytes 0-59289/59290
Content-Type:audio/ogg
Date:Fri, 15 Mar 2013 08:58:14 GMT
Expires:Sun, 14 Apr 2013 08:58:14 GMT
Keep-Alive:timeout=5, max=98
Last-Modified:Sat, 09 Mar 2013 14:23:45 GMT
Server:Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1

这是我在VPS上得到的头(不工作):

Request URL:http://www.mysite.com/jazz.ogg
Request Headersview source
Accept-Encoding:identity;q=1, *;q=0
Cache-Control:max-age=0
Range:bytes=0-
Referer:http://www.mysicians.com/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.160 Safari/537.22

我希望你能帮助我,这样我就能睡个好觉了:)由于

我自己找到了一个解决办法,希望能对一些人有所帮助。

和你一样,在我的本地服务器Wamp上一切正常。问题是在我的VPS与Apache。在我的。htaccess文件中添加以下行后(第1行应该足以用于ogg扩展名):

AddType audio/ogg .oga
AddType video/ogg .ogv .ogg
AddType video/webm .webm
AddType video/mp4 .mp4

我在Google chrome浏览器上仍然有问题,我可以在Firefox, Internet Explorer, Safari中播放声音,但chrome不行。我搜索了好几个小时也没有找到答案。这可能与编解码器有关,但我不确定。

最后,我通过调用一个声音正常播放的距离源来解决这个问题。

在html5中使用不同来源确保声音在所有浏览器中播放的示例:
<audio id="sound">
  <source src="sound.wav" />
  <source src="http://www.another-website.com/sound.mp3" />
  <source src="sound.mp3" />
  <source src="sound.ogg" />
  <embed  src="sound.mp3"></embed>
</audio>

最新更新