AJAX Access-Control-Allow-Origin

时间:2015-12-15 11:38:48

标签: php ajax .htaccess mod-rewrite

我在尝试运行m3u8视频时收到错误:: No' Access-Control-Allow-Origin'标头出现在请求的资源上。起源' DeepSeeWeb'因此不允许访问。

<!DOCTYPE html>
<html>
<head>
    <meta charset=utf-8 />
    <title>Video</title>

    <link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
    <script src="http://vjs.zencdn.net/4.12/video.js"></script>
    <script src="https://github.com/videojs/videojs-contrib-media-sources/releases/download/v0.1.0/videojs-media-sources.js"></script>
    <script src="https://github.com/videojs/videojs-contrib-hls/releases/download/v0.11.2/videojs.hls.min.js"></script>

</head>
<body>
<h1>Video</h1>

<video id="my_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="268"
       data-setup='{}'>

    <source src="http://my~server.com/recordings/91/2015-12-15/91_1450161600/91_1450161600.m3u8" type='application/x-mpegURL'>


</video>

<script>
    var player = videojs('my_video_1');
</script>

</body>
</html>

http://my~server.com/我添加了.htaccess,但它没有效果。

<IfModule mod_rewrite.c>

   RewriteEngine on
   <IfModule mod_headers.c>
                Header add Access-Control-Allow-Origin "*"
        Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
        Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
   </IfModule>

</IfModule>

1 个答案:

答案 0 :(得分:0)

是否有任何PHP处理您的视频请求?您可以控制在&#34;视频流&#34;之前发送的实际标头。启动。

我不确定你所拥有的.htaccess是否也会覆盖你所指的子文件夹。