wordpress htaccess is hijacking my .mp4 files

I am running wordpress 3.2rc2 multisite.

I inserted a few .mp4 videos into the root of my domain so that I can run a few basic tests with the jw player.

When I try to access the url to the .mp4 video, I somehow end up with a wordpress 404 page. This is also causing errors within the jw player saying that either the file is not found, or access is denied. Permissions are 644 on the mp4 files, and the owner/group is correct.

Why is this happening and how do I fix it so that wordpress stops messing with my mp4 files?

Also: can someone please add the mp4 tag, I don’t have enough rep to do this yet.

Here is my htaccess file:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

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

Edit
If I use the wordpress media uploader, then I can access the mp4 videos just fine. I just can’t place them anywhere else on the server which is a problem.

Anyone have any further ideas as to why wordpress is screwing with my mp4s when in other directories or even when they are in the root?

2 Answers
2

A missing mime type should not cause a 404 page but the AddType needs to be wrapped in <IfModule mod_mime.c> tags.

<IfModule mod_mime.c>
    AddType video/mp4 .mp4 .m4v
    AddType video/mpeg .mpeg .mpg .mpe
    AddType video/asf .asf .asx .wax .wmv .wmx
    AddType video/avi .avi
    AddType video/quicktime .mov .qt
    AddType audio/ogg .ogg
</IfModule>

I’m running jw player on a multisite and I had to use absolute urls to access the player and the file. I created a folder in my site root that contained the player and files then wrote a function to display the video and enqueued the swfobject using wp_enqueue_script.

 add_action( 'template_redirect', 'load_swf_object' );
 function load_swf_object() {
    wp_enqueue_script('swf_object', '/jw/swfobject.js');
}

function c3m_play_the_video() {  
 echo "<div id='front-vid'>
        <div id='videospace'>This text will be replaced</div>
        <script type="text/javascript">
      var so = new SWFObject('http://example.com/jw/player.swf','mpl','520','350','9');
      so.addParam('allowfullscreen','true');
      so.addParam('allowscriptaccess','always');
      so.addParam('wmode','opaque');
      so.addVariable('file','http://example.com/jw/video/video_name.mp4');
      so.addVariable('image','http://example.com/jw/video/video-face.jpg');
      so.addVariable('skin','http://example.com/jw/skins/glow.zip');
      so.addVariable('bufferlength','3');
      so.write('videospace');
      </script>
        </div>";
}

Leave a Comment