wiki:VirtualVideoClipUrlRewrite

Rewriting URLs for Virtual Video Clips

back


Virtual Video Clips

We have a full length video available at the following URL 'http://www.example/com/video.mp4'. A preview can be provided by adding the 'start' and 'end' parameters, say for example we want to use 30 seconds of preview starting at the 15th second. We then have the following URL 'http://www.example.com/video.mp4?start=15&end=45'.

This will work fine when using wget / curl, unfortunately a lot of Flash players don't behave correctly as they don't allow video URLS with query parameters in them. They just blindly append '?start=xyz' to the URL making it invalid.

To work around this we can move the start and end parameters to the server side configuration. This has a couple of advantages:

  • The user doesn't see the '?start=15&end=45' parameters any more.
  • Flash players assuming that they are adding the first query parameters work again.

So, let's replace the preview URL 'http://www.example.com/video.mp4?start=15&end=45' by 'http://www.example.com/video.mp4/preview' and move the URL rewriting to the server side configuration.

Apache

In your .htaccess:

RewriteEngine On

# From: http://www.example.com/video.mp4/preview?start=xyz&foo=bar
# To: http://www.example.com/video.mp4?start=xyz&foo=bar&vbegin=15&vend=45
RewriteRule ^(.*)/preview\?(start=.*)$ $1?$2&vbegin=15&vend=45 [L]

Lighttpd

IIS

Nginx

Last modified 8 years ago Last modified on 05/30/09 18:31:07